2010-06-20 38 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