简体   繁体   English

UITableView侦听用户滚动而不是其委托

[英]UITableView listen user scroll not its delegate

There is a UITableview. 有一个UITableview。 When i insert a row ,i call this method 当我插入一行时,我调用此方法

[tableView insertRowsAtIndexPaths:@[lastRow] withRowAnimation:UITableViewRowAnimationLeft];
[tableView scrollToRowAtIndexPath:lastRow atScrollPosition:UITableViewScrollPositionBottom animated:NO];

To keep the newest cell show. 保持最新的单元格显示。 how can i listen user scroll the tableview. 我该如何收听用户滚动tableview。 i tried add UIScrollview delegate - scrollViewDidScroll , but this method also listen 我尝试添加UIScrollview委托scrollViewDidScroll ,但是此方法也听

 [tableView scrollToRowAtIndexPath:atScrollPosition:animated:] 

I think you should try below code it is working fine for me 我认为您应该尝试下面的代码,它对我来说很好

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];

[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];

Here selectedIndex is which you need to show. 在这里您需要显示selectedIndex

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

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