Swapping tableView into another view within UITableViewController
I'm trying to resize the tableview of a UITableViewController so I can also put some other content in the view. So I'm trying to swap the tableview into a new view. The following works, but if I try to reference self.tableview later, it returns null. What am I doing wrong ?
- (void)viewDidLoad {
[super viewDidLoad];
UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
self.tableView.frame = CGRectMake(0, 0, 320, 200);
[view addSubview:self.tableView];
self.view = view;
}
Yes, I can probably just use a UIViewController and create my tableview there. I was just trying to avoid doing that if I can, and get the freebies of UITableViewController
为了解决我刚才对tableView的问题,并覆盖了tableview getter
- (UITableView*)tableView{
return myTableView;
}
- (void)viewDidLoad {
[super viewDidLoad];
myTableView = [super tableView];
UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
self.view = view;
myTableView.frame = CGRectMake(0, 0, 320, 200);
[view addSubview:myTableView];
}
链接地址: http://www.djcxy.com/p/84292.html
