我有一个自定义UITableViewCell
其中我有两个UIViews
。我想要更改BackgroundColor半径以及UIViews
的一些其他属性。无法更新自定义UITableViewCell中的子视图
但我无法这样做。
这是我的setUp。
步骤1:
Create A Custom Cell with XIB.
步骤2:在XIB
一进Cell Identifer
名CustomCell
。
步骤3:在viewDidLoad
UINib *nib = [UINib nibWithNibName:@"CustomCell" bundle:nil];
[[self mTableView] registerNib:nib forCellReuseIdentifier:@"CustomCell"];
步骤4实例化NIB
:细胞为行索引方法:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Create an instance of ItemCell
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomCell"];
[cell updateCellView];
return cell;
}
步骤5:两次检查的出口连接都是好的。
第6步:自定义单元格类:
#import "TransportCell.h"
@implementation TransportCell
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)updateCellView
{
self.backgroundView.backgroundColor = [UIColor redColor];
}
@end
此代码对我的手机浏览无影响。
我调试了代码。当我登录了backgroundView
我得到nil
时updateCellView
方法被调用:
这里是我的CustomCell的厦门国际银行:
我必须改变内部的UIView属性(蓝色。颜色)
尝试self.backgrondColor = [UIColor redcolor] – riddhi
它会改变单元格背景颜色 – Dalvik
你有没有为你的backgroundview插座或连接到你的视图? – riddhi