I have a view controller that contains a navigation bar, a tabular view and a toolbar. I included the UITableViewDelegate in the view controller and correctly assigned the table data source and passed the view controller through the storyboard. The table view loads its data from the remote database, as soon as the table scrolls to the last cell, more data is loaded into the table. I achieved this using the scrollViewDidScroll and indexPathForRowAtPoint methods, as described in the following post: How to find out when the UITableView scrolled to the end on the iPhone . However, when I launch the application and look at the table, the only index path returned by indexPathForRowAtPoint is the one that was located at the specified point while the table was loading. Here is the code and the output that I get when scrolling:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGPoint bottomPoint = CGPointMake(160, 430); CGPoint topPoint = CGPointMake(160, 10); NSLog(@"%d", [[_tableView indexPathForRowAtPoint:bottomPoint] row]); }
Each scroll displays the following:
2013-06-08 00:56:45.006 Coffee[24493:907] 3 2013-06-08 00:56:45.012 Coffee[24493:907] 3 2013-06-08 00:56:45.040 Coffee[24493:907] 3 2013-06-08 00:56:45.069 Coffee[24493:907] 3 2013-06-08 00:56:45.088 Coffee[24493:907] 3 2013-06-08 00:56:45.105 Coffee[24493:907] 3 2013-06-08 00:56:45.135 Coffee[24493:907] 3 2013-06-08 00:56:45.144 Coffee[24493:907] 3 2013-06-08 00:56:45.173 Coffee[24493:907] 3 2013-06-08 00:56:45.180 Coffee[24493:907] 3
Where 3 is the index cell of the cell, the bottom point is on when the controller boots up. What am I doing wrong and why is this happening? Does this have anything to do with the fact that the UITableView is inside the parent controller?
source share