objective-c - UITableView 部分页脚在滚动时重叠

标签 objective-c ipad

我有一个 UItableview,我以编程方式为其设置了部分页眉和页脚。

最初我遇到了部分标题在滚动上重叠的问题,我使用 scrollViewDidScroll 委托(delegate)解决了这个问题

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    heightForHeader = 40.0;
    if (scrollView.contentOffset.y<=heightForHeader&&scrollView.contentOffset.y>=0) {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    } else if (scrollView.contentOffset.y>=heightForHeader) {
        scrollView.contentInset = UIEdgeInsetsMake(-heightForHeader, 0, 0, 0);
    }
}

现在下一个问题是滚动时重叠的部分页脚。

你能帮我解决这个问题吗?

最佳答案

您是否为页眉和页脚设置了自定义高度?

您的 TableView 委托(delegate)应实现此方法:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

应该返回适​​当的值。

如果您返回的值小于页眉和页脚 View 的值,那么它们可能会重叠。

关于objective-c - UITableView 部分页脚在滚动时重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7238246/

相关文章:

iOS 解析表结构

iphone - iOS - 确定选择了哪个 MKPointAnnotation

iphone - UITableView - 如何只显示包含数据的行

iphone - 在 iPad 上按顺序加载多张图像

ios - 您创建的对象的所有权

ios - 如何将 2 个垂直堆叠的 UILabels 垂直居中

objective-c - 观察者通知的 NSNotification 顺序

ios - 在 Split View的弹出式 Controller 中以 UIModalPresentationFormSheet 样式呈现的对话框在旋转后消失

iphone - 在 GooGle map 上添加 UITextField 和 UiButton

iphone - 呈现图像裁剪界面