- I have a
UITableViewCell
which is defended programmatically. - I am trying to attach to it a simple Nib file.
- Nib has been created and fully configured. And I can add to Nib an images with IB and see that they appears when app is running. This means that Nib is loaded.
- But I still can not change any outlets (labels, buttons) on a Nib with code?
- What I should do solve the bit problem?
I use following code:
- (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
...
}