[英]UITableView Can't scroll to last Row
I have a table view set up with a couple of different rows where each row contains two UITextViews. 我有一个表视图,其中设置了几个不同的行,其中每行包含两个UITextViews。 When the user starts editing a text view I want that table view cell where its located to be scrolled to the top of the table view.
当用户开始编辑文本视图时,我希望将其所在的表格视图单元格滚动到表格视图的顶部。 To scroll I am using:
要滚动,我正在使用:
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
This is working fine except for the last two rows, where the row is scrolled a little bit but not all the way to the top. 除最后两行外,此方法工作正常,该行略微滚动了一点,但并非一直滚动到顶部。
I think the issue is that the content size of the table view is not large enough to allow scrolling but I don't know how to adjust it in a proper way. 我认为问题在于表格视图的内容大小不足以允许滚动,但是我不知道如何以适当的方式进行调整。
Any help would be appreciated. 任何帮助,将不胜感激。
Thanks in Advance! 提前致谢!
Just call this method in viewDidLoad and your problem will get solved. 只需在viewDidLoad中调用此方法即可解决您的问题。
- (void)configureInsetsOfTableView
{
CGFloat defaultSpacing=10.0f;
[self.tableView setContentInset: UIEdgeInsetsMake(0.f, 0.f, self.navigationController.navigationBar.bounds.size.height + [UIApplication sharedApplication].statusBarFrame.size.height +defaultSpacing, 0.f)];
[self.tableView setScrollIndicatorInsets:UIEdgeInsetsMake(0.f, 0.f, self.navigationController.navigationBar.bounds.size.height + [UIApplication sharedApplication].statusBarFrame.size.height +defaultSpacing, 0.f)];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.