Reload UITableView with a different number of rows?

TableView reloadData relies entirely on the data source methods! So, the only way you would see your data source methods beind ignored would be that you have not set the data source (and perhaps delegate) of your table view to be the object you want to be the data source. You can set these through Interface Builder, or programatically, e.g. : tableView.

DataSource = self; tableView. Delegate = self.

Both the datasource/delegate are set, but I get the feeling that it only reloads data for each cell already in the table, in this case 0. – Tom Walters Apr 27 at 15:41 That shouldn't be the case. A typical implementation for numberOfRowsInSection: is to return the count of objects in an array.So I have to believe that a data source method like that is consulted often.

You could set a breakpoint in that method to verify if it is being called. Of course, you have to actually call reloadData:. I assume you're at least doing that, right?

:-) – MarkGranoff Apr 27 at 16:03 Right, I set the breakpoint, and found that it is called every time the view loads, and double checked I was calling reloadData :) And now it appears to be working. This must have been to do with another view writing to a file and messing it up - yay for misc errors! But at least we know that the numberOfRowsInSection is called every time now.

– Tom Walters Apr 27 at 16:10 Nice. I love it when odd behavior just "goes away" but the Professional Software Developer in me always is unnerved by not knowing exactly what was going on in the first place... :-) – MarkGranoff Apr 27 at 16:13 Yeah I know the feeling, but I'm not worried, I'm sure it'll come back around and get me one day soon... – Tom Walters Apr 27 at 16:15.

If yes it is probably incorrect, because -viewDidLoad is called only once - when view of the corresponding UIViewController is created (on the first usage). Maybe you should take a look at -viewWillAppear which is called(assuming correct usage of UIViewController) whenever view is going to be displayed. The other possible reason is that if you do use -viewWillAppear (or -viewDidAppear) it is not triggered at all.

This can happen if you use a custom UIViewController hierarchy.In that case you must call it with your own hands (there are exceptions - UINavigationController for example does this for you, but simple someView addSubview:myController. View doesn't). Also please check if delegates are set correctly and tableView is not equal to nil (as you know messages to nil are just ignored).

Yep, using -viewDidAppear, I've checked this method, and it is being called every time the view is loaded (tableview controller within a tabbar controller). And the delegates are indeed set up. Thanks for the response though!

– Tom Walters Apr 27 at 15:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions