UITableViewCell
以编程方式进行辩护。我使用以下代码:
- (UIView *)viewFromNib
{
Class class = [self class];
NSString *nibName = NSStringFromClass(class);
NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
UIView *view = [nibViews objectAtIndex:0];
return view;
}
- (void)addSubviewFromNib
{
UIView *view = [self viewFromNib];
self.bounds = view.bounds;
self.frame = view.frame;
self.viewNib = view;
[self addSubview:view];
[self.Button setTitle:@"hello"
forState:UIControlStateNormal]; // problem: button label is not changed
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
...
[self addSubviewFromNib]; // adds subview from my Nib
...
}
答案 0 :(得分:0)
将界面生成器中nib文件的文件所有者的类更改为正确的类。像通常在界面构建器中那样引用插座。