簡體   English   中英

分頁UITableView,設置內容偏移量

[英]Pagination UITableView, setting the content offset

我正在嘗試在我的UITableView中實現分頁。 我的細胞高度幾乎全屏,代碼在這里:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return  ([[UIScreen mainScreen] bounds].size.height) - (self.navigationController.navigationBar.frame.size.height)-20;

}

我已在接口構建器中設置了分頁,但偏移量略有錯誤。 我想這是因為它使用窗口框架的大小作為其偏移量。 無論如何我可以調整它以匹配我的表格單元格高度? 任何提示都會非常感激。

如果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);

如果要顯示表視圖的頂部,請在-viewWillAppear:方法中使用以下代碼

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

希望你找到答案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM