Check out the Apple State recovery example to find out how. The magic fix happens in the decodeRestorableStateWithCoder method with a call to reloadData :
MyTableViewController.m
// this is called when the app is re-launched - (void)decodeRestorableStateWithCoder:(NSCoder *)coder { // important: don't affect our views just yet, we might not visible or we aren't the current // view controller, save off our ivars and restore our text view in viewWillAppear // NSLog(@"MyTableViewController: decodeRestorableStateWithCoder"); [super decodeRestorableStateWithCoder:coder]; self.tableView.editing = [coder decodeBoolForKey:kUnsavedEditStateKey]; [self.tableView reloadData]; }
Note that it is strange that they encode the editing state because editing ends with their background input notification handler before starting saving, so it always restores non-editing. They also try to set self.tableView.editing instead of self.editing so that the edit button does not refresh. Also, pay attention to the comment that it does not affect the views, which is strange, firstly, given that they really affect the views, and the second viewWillAppear is called before the decoding state. Given these errors, I would not use this example to customize your programming skills.
Another answer points to a reload in indexPathForElementWithModelIdentifier which is not a good idea, because it is called several times (at least twice) to find the different index paths of the visible and selected objects.
malhal
source share