views:

2772

answers:

1

I have a UITableViews inside of a TabBarController that are populated with separate arrays of data. Due to web syncing, this array updates, and I'd like to update the table.

Calling:

[self.tableView reloadData]

will reload content in existing cells, but I need to add cells for the new data. It seems that this method is not calling

-tableView:tableView numberOfRowsInSection:section

again, which is where I dynamically specify the number of rows. Any ideas? I've read all the docs I can find, and haven't caught onto anything. Is this a application design issue?

Thanks!

+2  A: 

Take a look at these functions in UITableView:

-(void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
-(void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
Ed Marty
So I have to add/remove rows. I can't just re-specify the number of rows and redraw them all? ie: make the part in -tableView:tableView numberOfRowsInSection:section dynamic and somehow reload it?
Michael Grinich
calling reloadData SHOULD call those methods. If it's not, try checking the value of the tableView's delegate/datasource to make sure it's correct immediately before calling reloadData. On the other hand, if you call these functions, the added sections/rows animate in.
Ed Marty
Ahh. Yep. It was a delegate issue. That method works correctly.
Michael Grinich