Tableview not reloading after data change : IOS 5

天大地大妈咪最大 提交于 2019-12-12 02:47:00

问题


I need help in following scenario.

I am building an app that displays tableview. If the user tap an entry it goes to the detailed screen. In the detail screen, I have a button to delete this entry. It deletes the entry from the data source and dismiss the modal.

But after dismissing the modal, table view data is not refreshing.

If I go back to parent view controller and then again come back to child screen, it refreshes the count.

I read few similar posts and found the following solution.

[tableview reloadData];

Or

[self.tableView reloadData];

In - (void)viewDidAppear:(BOOL)animated of child screen. But its not refreshing the table view.

Please help.


回答1:


For completeness, the full implementation would be:

- (void)viewWillAppear:(BOOL)animated
{
    // Do stuff like reload the tableview data...
    [self.tableView reloadData];
}

If it's not working you have a problem elsewhere in your code.




回答2:


If the tableview is in the parent viewcontroller, I suggest that placing reloadData: method at viewWillAppear: of the parent.

(void)viewWillAppear:(BOOL)animated
{
    [self.tableView reloadData];
}

I'm sure that the method will be called when the detailed viewcontroller dismissed.




回答3:


Go through this code:

- (void)viewWillAppear:(BOOL)animated
{ 
    [self.tableView reloadData];
}


来源:https://stackoverflow.com/questions/9678531/tableview-not-reloading-after-data-change-ios-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!