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

时间:2016-06-23 06:46:31

标签: ios objective-c iphone uitableview uiscrollview

有一个UITableview。当我插入一行时,我称之为

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

保持最新的细胞展示。我怎么能听用户滚动tableview。 我尝试添加UIScrollview委托 - scrollViewDidScroll,但此方法也会监听

 [tableView scrollToRowAtIndexPath:atScrollPosition:animated:] 

1 个答案:

答案 0 :(得分:0)

我认为你应该尝试下面的代码,它对我来说很好

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

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

此处selectedIndex是您需要展示的。