首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自定义UITableView页脚不会锁定在底部,因为表视图是滚动的

问自定义UITableView页脚不会锁定在底部,因为表视图是滚动的
EN

Stack Overflow用户
提问于 2014-03-11 06:00:14
回答 1查看 6.3K关注 0票数 6

我检查了所有这些UITableView, make footer stay at bottom of screen?

tableFooterView property doesn't fix the footer at the bottom of the table view

iOS - viewForFooterInSection sticking to bottom of UITableView

Proper way to implement a footer in UITableView

类似的问题,但不幸的是,我的问题还没有解决。

我必须实现一个自定义页眉和页脚视图与按钮在里面。我用.nib文件创建了单独的UIView子类。在我的视图控制器中,我调用这些方法来注册页眉和页脚视图的nib。

代码语言:javascript
复制
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    CustomTableHeaderView *view = [CustomTableHeaderView header];
    view.delegate = self; //setting delegate to receive callbacks as the buttons inside the view are pressed
    return view;
}

- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    CustomTableFooterView *view = [CustomTableFooterView footer];
    view.delegate = self;
    return view;
}

其中,作为自定义视图中的类方法,注册一个.nib文件并返回视图。然而,实施的是;

代码语言:javascript
复制
+ (CustomTableHeaderView*)header
{
    return [[[NSBundle mainBundle]loadNibNamed:@"CustomTableHeaderView" owner:nil options:nil]objectAtIndex:0];
}

页脚的类似实现。

问题是,当表视图滚动时,页脚视图不会锁定在底部。i-e,当视图中有更多的行可容纳时,页脚视图隐藏,并在所有行向下滚动到结束时显示。不管有多少行要滚动,我都想锁定视图底部的页脚视图。这个实现完美地实现了页眉视图,因为它在行被滚动时锁定在顶部,但是页脚视图是与行一起滚动的。

我也尝试过self.tableview.tablefooterview属性,但也没有帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-11 06:25:38

不幸的是,这不是表节页脚的工作方式。为了在底部完成锚定视图,需要手动将其作为子视图添加到UIView中。

如果将其作为子视图添加到您的UITableView中,则需要通过在scrollViewDidSroll:中更改其框架来保持其锚定。如果将其作为子视图添加到包含UIView的UITableView中,则只需将其静态地放在底部即可。在这两种情况下,您可能都希望调整表视图的contentInset,并在底部设置一个内嵌,这样您就可以在锚定的页脚上方滚动内容。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22317621

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档