I am trying to implement pagination in my UITableView. My cells heights are pretty much fullscreen, code here:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return ([[UIScreen mainScreen] bounds].size.height) - (self.navigationController.navigationBar.frame.size.height)-20;
}
I have set paging enabled in the interface builder however the offset is slightly wrong. I guess this is because it uses the size of the window frame as its offset. Is there anyway I can adjust this to match my table cell heights? Any tips would be really appreciated.
If TabBar
or bottom of the view is covering the TableView
cells then use following code in -viewDidLoad:
method
self.edgesForExtendedLayout = UIRectEdgeAll;
// self.tableView.contentInset = UIEdgeInsetsMake(0.0f, 0.0f, CGRectGetHeight(self.tabBarController.tabBar.frame), 0.0f);
self.tableView.contentInset = UIEdgeInsetsMake(0.0f, 0.0f, 75.0f, 0.0f);
If you want to present the top of your table view when it appears the use following code in -viewWillAppear:
method
[self.tableView reloadData];
self.tableView.contentOffset = CGPointMake(0, 0 - self.tableView.contentInset.top);
Hope you find your answer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.