我的tableView下面还有数据,滑倒最下面仍然显示不全。
1. 在网上查了很多资料,也尝试了很多次,发现是tableView的height问题,因此采用了下面的方法,暂时解决了燃眉之急。
#pragma mark - 自适应tableView,调整tableView高度,避免被navigationBar或tabBar遮挡
-(void) autofitTableView{
//去除status bar 和 navigationbar的高度
CGRect viewFrame = self.view.frame;
// NSLog(@"viewFrame = (%f,%f,%f,%f)", viewFrame.origin.x, viewFrame.origin.y, viewFrame.size.width, viewFrame.size.height);
CGRect tableViewFrame = self.pullTableView.frame;
// NSLog(@"tableViewFrame = (%f,%f,%f,%f)", tableViewFrame.origin.x, tableViewFrame.origin.y, tableViewFrame.size.width, tableViewFrame.size.height);
//获取屏幕尺寸
CGRect screenRect = [UIScreen mainScreen].applicationFrame;
CGFloat screenHeight = screenRect.size.height;
// NSLog(@"screen height = %f", screenHeight);//460
CGRect statusBarRect = [[UIApplication sharedApplication] statusBarFrame];
CGFloat statusBarHeight = statusBarRect.size.height;
// NSLog(@"statusBar height = %f", statusBarHeight);//20
CGFloat tabbarHeight = self.tabBarController.tabBar.bounds.size.height;//
// NSLog(@"tabBar height = %f", tabbarHeight);//0
CGFloat navHeight = self.navigationController.navigationBar.frame.size.height;
// NSLog(@"navigationBar height = %f", navHeight);//0
//去掉navigationBar的高度
CGFloat viewHeight1 = self.view.frame.size.height;
// NSLog(@"view height1 = %f", viewHeight1);//460
CGFloat viewHeight2 = self.view.bounds.size.height;
// NSLog(@"view height2 = %f", viewHeight2);//460
CGFloat viewHeight3 = self.tabBarController.view.frame.size.height;
// NSLog(@"view height3 = %f", viewHeight3);//460
CGRect frame = [self.pullTableView frame];
CGFloat height1 = viewHeight1 - tabbarHeight - navHeight;
// NSLog(@"height1 = %f", height1);//480
CGFloat height2 = screenHeight - tabbarHeight - navHeight;
// NSLog(@"height2 = %f", height2);//460
frame.size.height = height2;
// self.tableBulletin.frame = frame;
self.pullTableView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - self.tabBarController.tabBar.frame.size.height);
self.navigationController.navigationBar.translucent = NO;
}
2.