I have rotated my table view by 90°. Now I want to get indexpath of middle cell. When table view is not scrolling, it is showing 3 cells. What I want is, when table view stops scrolling, it should middle cell of green color. Sometimes I get wrong indexpath when more then 3 cells are visible while fast scrolling.
I have attached image for reference
Asked
Active
Viewed 836 times
0
rmaddy
- 307,833
- 40
- 508
- 550
Bhanupriya
- 1,192
- 1
- 8
- 19
-
4Are you seriously using a table view? Why aren't you using a collection view? – nhgrif May 07 '14 at 11:36
-
@nhgrif , actually it a infinite scrolling table view. I have used following link for this: http://stackoverflow.com/questions/10404116/uitableview-infinite-scrolling and answer given by Frank Gorman. Now at the end of project, we can not change approach. Any help would be appreciated. – Bhanupriya May 09 '14 at 12:43
2 Answers
2
try this
NSIndexPath *middleIndexPath = [tableView indexPathForRowAtPoint:CGPointMake(tableView.center.y, tableView.center.x)];
UITableViewCell *middleCell = [tableView cellForRowAtIndexPath:middleIndexPath];
Vijay-Apple-Dev.blogspot.com
- 25,614
- 7
- 66
- 75
-
-
CGPointMake(tableView.center.x, tableView.center.y) try this – Vijay-Apple-Dev.blogspot.com May 09 '14 at 13:10
0
You can get contentOffset of table view. With contentOffset, you can calculate current row (contentOffset.y / row height)
huync
- 7,375
- 5
- 32
- 46