0

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 referenceThis is my horizontal table view and I want to show green color for middle cell

rmaddy
  • 298,130
  • 40
  • 468
  • 517
Bhanupriya
  • 1,164
  • 1
  • 8
  • 18
  • 4
    Are 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 Answers2

2

try this

NSIndexPath *middleIndexPath = [tableView indexPathForRowAtPoint:CGPointMake(tableView.center.y, tableView.center.x)];

UITableViewCell *middleCell = [tableView cellForRowAtIndexPath:middleIndexPath];
0

You can get contentOffset of table view. With contentOffset, you can calculate current row (contentOffset.y / row height)

huync
  • 7,009
  • 4
  • 31
  • 42