使用UITableBarController加UITableView时,底部被遮挡
一般通过继承UITableViewController,是不会发生底部被遮挡的问题,主要是因为UITableView的Frame系统自动设置。在UINavigationController加UITableBarController的结构时,通过在UIViewController中添加UITableView时,设置UITableView的高度等于UIViewController的高度,那么就会出现底部被遮挡的情况。
代码如下:
CGRect tableViewFrame = CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT);
UITableView *tableView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStyleGrouped];
以上代码中,tableViewFrame的高度设置有问题(64是navigationBar的高度加状态栏的高度),正确设置代码如下:
CGFloat tableViewY = 64;
CGFloat tableViewH = self.view.frame.size.height - self.tabBarController.tabBar.frame.size.height - tableViewY;
CGRect tableFrame = CGRectMake(0, tableViewY, SCREEN_WIDTH, tableViewH);
UITableView *manageView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStyleGrouped];