iOS 9.2

Is there a trick to using UITableView -reloadData? I can't get it to do 
anything.

My view controller has a UITableView instance (VC is both UITableView delegate 
and dataSource), and I populate it with cells from my data source via the 
delegate callback method -tableView:cellForRowAtIndexPath:. That works fine. 

Now, when the data source has additional data, it calls -reloadData to 
rebuild/redisplay the table view, but this has no effect. The delegate callback 
method -tableView:cellForRowAtIndexPath: doesn't get invoked, and the contents 
of the table view don't change. In the debugger, I've verified that the 
UITableView property is valid:

_sbsTableView is: <UITableView: 0x14b29000; frame = (20 74; 528 188); 
clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 
0x146f22a0>; layer = <CALayer: 0x14645640>; contentOffset: {0, 0}; contentSize: 
{528, 616}>

The reload doesn't reload the table, causing an index out of range exception 
downstream when trying to access a row that -reload should have added. 

  // Reload the table's data
  [_sbsTableView reloadData];  // no visible change onscreen
  // Reposition the table view to display the new entry
  NSIndexPath *indxPath = [NSIndexPath indexPathForRow:user_no
                                             inSection:sec_no];
  [_sbsTableView selectRowAtIndexPath:indxPath   // <- exception
                             animated:YES
                       scrollPosition:UITableViewScrollPositionMiddle];
  [_sbsTableView scrollToRowAtIndexPath:indxPath
                       atScrollPosition:UITableViewScrollPositionMiddle 
                               animated:YES];


The docs say: 

1. "The table view’s delegate or data source calls this method when it wants 
the table view to completely reload its data."

2. "Call this method to reload all the data that is used to construct the 
table, including cells, section headers and footers, index arrays, and so on."

Wouldn't that necessitate the invocation of the delegate callback method 
-tableView:cellForRowAtIndexPath:? FWIW, the next time the app is run, the 
additional data does appear in the table.

There must be something obvious I'm overlooking...
-Carl

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to