简体   繁体   English

分页UITableView,设置内容偏移量

[英]Pagination UITableView, setting the content offset

I am trying to implement pagination in my UITableView. 我正在尝试在我的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 如果TabBar或视图底部覆盖TableView单元格,则在-viewDidLoad:方法中使用以下代码

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 如果要显示表视图的顶部,请在-viewWillAppear:方法中使用以下代码

[self.tableView reloadData];
self.tableView.contentOffset = CGPointMake(0, 0 - self.tableView.contentInset.top);

Hope you find your answer 希望你找到答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM