我有一个UITableView,它的内容是动态变化的,就像一个先进先出堆栈。单元格将添加到底部,并从顶部删除。
这非常好用,我可以滚动到indexPath,这样最新的消息总是向下滚动到底部(就像聊天应用程序一样)。
现在.。我想在该表部分添加一个页脚。不是使用
SrollToRowAtIndexPath
我希望能够滚动到tableFooterView。
任何想法,我可以做到这一点,将不胜感激。
发布于 2013-06-19 07:04:51
我使用它来滚动到tableView的页脚视图:
[self.tableView scrollRectToVisible:[self.tableView convertRect:self.tableView.tableFooterView.bounds fromView:self.tableView.tableFooterView] animated:YES];
发布于 2010-11-15 12:19:15
将UITableView
滚动到其footerView底部的最好方法是简单地设置内容偏移量。您可以使用contentSize
和当前bounds
来计算底部
这就是我的做法。
CGPoint newContentOffset = CGPointMake(0, [self.instanceOfATableView contentSize].height - self.instanceOfATableView.bounds.size.height);
[self.instanceOfATableView setContentOffset:newContentOffset animated:YES];
发布于 2011-11-19 15:48:06
感谢iphone_developer,下面是我所做的:
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[tableView numberOfRowsInSection:0]-1 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
然后,当我添加行时,我调用了这个函数,我的tableView的页脚视图保持可见
Swift版本:
tableView.scrollToRow(at: IndexPath(row: self.tblview.numberOfRows(inSection: 0) - 1, section: 0), at: .top, animated: true)
https://stackoverflow.com/questions/1355674
复制相似问题