2010-06-20 43 views
0

我想打电话给的UITableView/UIScrollView的scrollToItemAtIndex

[tableView scrollToItemAtIndex: [tableView indexForCell: firstVisibleCell] atScrollPosition: UITableViewScrollPositionTop animated:YES]; 

要强制我的表“捕捉”到第一个可见项目。这工作正常,但我只接到一个电话

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView 

当滚动必须完成(这是在文件中说明)。无论如何,我可以得到firstVisibleCell的偏移量,所以我可以做一个比较,看看是否需要滚动?

回答

1

使用方法- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath

NSIndexPath *indexPath = [tableView indexForCell:firstVisibleCell]; 
CGRect rect = [tableView rectForRowAtIndexPath:indexPath]; 
+0

正是我一直在寻找。谢谢! – Kyle 2010-06-20 15:02:36