Table data doesn't reload in UITableViewController
This code works: [self.tableView reloadData]
, but if I extend the loadView
method of UITableViewControlle开发者_开发技巧r
like this:
- (void) loadView {
[super loadView];
float headerHeight = 80;
UIView *tableV = self.tableView;
CGRect tableFrame = self.tableView.frame;
self.view = [[UIView alloc] initWithFrame:self.tableView.frame];
[self.view release];
tableFrame.origin.y += headerHeight - [UIApplication sharedApplication].statusBarFrame.size.height;
tableFrame.size.height -= headerHeight;
tableV.frame = tableFrame;
[self.view addSubview:tableV];
}
the tableView data isn't reload. What am I doing wrong?
In a UITableViewController, self.view == self.tableView, so in line 7 (self.view = [[UIView...
) you're actually replacing both self.view and self.tableView.
If all you want is to move the table view down, try using contentInset.
精彩评论