Created
March 1, 2012 21:39
-
-
Save setoh2000/1953420 to your computer and use it in GitHub Desktop.
UITableViewでスクロール停止時に表示されるセルを予想する iOS5以降
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset | |
{ | |
UITableView *tableView = (UITableView *)scrollView; | |
int n = tableView.frame.size.height / _cellHeight; | |
if ((int)tableView.frame.size.height % (int)_cellHeight) n++; | |
for (int i = 0; i <= n; i++) { | |
NSIndexPath *indexPath = [tableView indexPathForRowAtPoint:CGPointMake(0, targetContentOffset->y + i * _cellHeight)]; | |
NSLog(@"scrollViewWillEndDragging - indexPath = %d", indexPath.row); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_cellHeightは事前にセルの高さを入れておくこと。
可変にするならindexPathからセルから求めて随時計算するようにすればよいかと。