开发者

Reloading a UITableView

开发者 https://www.devze.com 2023-03-09 02:55 出处:网络
I have a UITableView which holds Contacts (basically just a list of people). At the top of the UIViewController where that UITableView is, I have a button to add a new contact. When adding a new conta

I have a UITableView which holds Contacts (basically just a list of people). At the top of the UIViewController where that UITableView is, I have a button to add a new contact. When adding a new contact, a user presses a button "Done" to add that contact. I dismiss the view (which then makes the original view that has th开发者_运维知识库e UITableView in it show up) and attempt to reload the table to add the new contact. The new contact is added in the list of rows (an NSMutableArray), but it does not get refreshed when I call "reloadData" and the table won't update.

How and when can I update the UITableView to add the new contact?


Do you change numberOfRowsInSection: accordingly ?

You can avoid reloading entire table view by using:

insertRowsAtIndexPaths:withRowAnimation:


Did you checked your all your outlets connexions in Interface Builder. You should have 'delegate' , 'datasource' and naturally your IBOutlet (corresponding to your UITableView )connected to your object. There are 3 connexions !

0

精彩评论

暂无评论...
验证码 换一张
取 消