`

UITableView的最后一行在3.5寸屏上无法显示的问题

 
阅读更多

UITableView原本在iphone5上显示正常,但是在iphone4s上看不到最后一行

原因是UITableView的height计算错误,原来的代码:

self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 104, 320, 415) style:UITableViewStylePlain];

这里的415是写死的,根据568 - 20 - 44 - 49得到。但是在3.5寸屏上,高度只有480,所以造成这个BUG,正确的代码:

CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;// 568 in 4-inch,480 in 3.5-inch       
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 104, 320, screenHeight - 153) style:UITableViewStylePlain];


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics