简体   繁体   English

自定义UITableView页脚在滚动表视图时不会锁定在底部

[英]Custom UITableView Footer doesn't lock in the bottom as the table view is scrolled

I have checked all these UITableView, make footer stay at bottom of screen? 我已经检查了所有这些UITableView,是否使页脚停留在屏幕底部?

tableFooterView property doesn't fix the footer at the bottom of the table view tableFooterView属性不会将页脚固定在表格视图的底部

iOS - viewForFooterInSection sticking to bottom of UITableView iOS-viewForFooterInSection粘在UITableView的底部

Proper way to implement a footer in UITableView 在UITableView中实现页脚的正确方法

similar questions but unfortunately my problem hasn't resolved. 类似的问题,但不幸的是我的问题没有解决。

I have to implement a custom header and footer views with buttons inside. 我必须实现带有按钮的自定义页眉和页脚视图。 I have created separate UIView's subclasses with .nib files. 我用.nib文件创建了单独的UIView的子类。 In my view controller, I'm calling these methods to register nibs for header and footer view. 在我的视图控制器中,我正在调用这些方法来为页眉和页脚视图注册笔尖。

- (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;
}

Where as the class method in the custom views registers a .nib file and returns the view. 其中,作为自定义视图中的类方法,注册一个.nib文件并返回该视图。 However the implementation is; 但是实现是;

+ (CustomTableHeaderView*)header
{
    return [[[NSBundle mainBundle]loadNibNamed:@"CustomTableHeaderView" owner:nil options:nil]objectAtIndex:0];
}

Similar implementation for footer. 页脚的类似实现。

The problem is that the footer view doesn't lock at the bottom when the table view scrolls. 问题在于,表格视图滚动时,页脚视图不会锁定在底部。 ie, when there are more rows to fit inside the view, the footer view hides and is revealed when all the rows are scrolled down till the end. 也就是说,如果有更多行要放入视图中,则当所有行向下滚动到末尾时,将隐藏并显示页脚视图。 I want to lock the footer view at the bottom of the view no matter how much rows are there to scroll. 我想将页脚视图锁定在视图底部,无论要滚动多少行。 The header view has been implemented perfectly by this implementation as it is locked at the top while the rows are being scrolled, however the footer view is scrolled with the rows. 标题视图已通过此实现完美实现,因为在滚动行时将其锁定在顶部,但是页脚视图随行一起滚动。

I have also tried self.tableview.tablefooterview property but it didn't help either. 我也尝试过self.tableview.tablefooterview属性,但这也没有帮助。

Unfortunately thats not how table section footers work. 不幸的是,那不是表节页脚的工作方式。 In order to accomplish an anchored view at the bottom you will need to add it as a subview to your UIView manually. 为了在底部完成锚定视图,您需要将其作为子视图手动添加到UIView。

If you add it as a subview to your UITableView you will need to keep it anchored by changing its frame in scrollViewDidSroll: . 如果将其作为子视图添加到UITableView ,则需要通过在scrollViewDidSroll:更改其框架来使其锚定。 If you add it as a subview to the UIView containing your UITableView you can just place it statically at the bottom. 如果将其作为包含UITableViewUIView的子视图添加,则可以将其静态地放在底部。 In either case you probably want to adjust the contentInset of the table view with an inset at the bottom so that you can scroll your content up above the anchored footer. 无论哪种情况,您都可能希望调整表格视图的contentInset并在其底部插入一个小插图,以便可以将内容向上滚动到固定的页脚上方。

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

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