UITableView reload problem

I have a UITableView that is populated with an array, I have a button on the navigation bar that (when clicked) adds an item to the array and calls [self.tableView reloadData] on the UITableView. This causes numberOfRowsInSection to be called and return the correct number of rows (the number of elements in the array), but does not call cellForRowAtIndexPath. I created a new navigation based app to try and find a solution but has exactly the same problem! If anyone knows the answer, it would be greatly appreciated, I ripped what was left of my hair on the last day! I have put the source for a test project on my site at www.sofaracing.com/Downloads/Test3.zip

+1


a source to share


2 answers


Works for me!;)

In MainWindow.xib, you added a Root View Controller object (which is not part of the navigation controller) - remove it, not necessary. Then connect the refreshFriendsList output to the RootViewController NavigationItem button. Wha-la, magic!



By the way: you might need to clear the warning. And you might consider creating a class for your data model rather than using UIApplication sharedApplication.

+2


a source


I quickly debugged your test application. I couldn't find the root cause, but it seems that you have two different kinds of tables due to some errors in the Interface Builder setup.

If you initialize the original array with an element, cellForRowAtIndexPath is called correctly. If you examine an instance of self.tableView in this call and then in subsequent calls to refreshFriendsList, self.tableView points to a different instance.



2009-05-17 14:33:07.591 Test3[33580:20b] cellForRowAtIndexPath 0
2009-05-17 14:33:07.594 Test3[33580:20b] self.tableView: <UITableView: 0x52b9b0>
2009-05-17 14:42:36.810 Test3[33762:20b] numberOfRowsInSection: tableView <UITableView: 0x53bcd0> 

      

+1


a source







All Articles