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 810 times
0
![](../../users/profiles/1226963.webp)
rmaddy
- 298,130
- 40
- 468
- 517
![](../../users/profiles/3498925.webp)
Bhanupriya
- 1,164
- 1
- 8
- 18
-
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];
![](../../users/profiles/675170.webp)
Vijay-Apple-Dev.blogspot.com
- 25,484
- 7
- 65
- 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)
![](../../users/profiles/1639366.webp)
huync
- 7,009
- 4
- 31
- 42