I have a tab bar iPhone application with 4 tabs. In the Interface Builder I set view controllers for each tab.
I want to change style from plain to grouped for one UITableViewController.
I replace init method something like this:
- 开发者_运维知识库(id)init
{
self = [super initWithStyle:UITableViewStyleGrouped];
if (self != nil) {
// Initialisation code
}
return self;
}
but no luck.
There is no code where I can call initWithStyle method.
Please advice how to change style for my UITableViewController in tab bar.
If your view is created through Interface Builder the init method wont be used.
Objects loaded from a *.(nib|xib) are inited with:
- (id)initWithCoder:(NSCoder *)inCoder;
So you could override that or if doing your setup after -initWithCoder: is called is not a problem you could use:
- (void)awakeFromNib;
from the NSNibAwaking protocol.
May be this can help you
- (void)viewDidLoad { [super viewDidLoad]; self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
}
精彩评论