Domanda

This project is for iPhone with iOS 5 using ARC and Core Data.

All built in Xcode Storyboards, I have a UITabBarController with a few tabs. Three of these views are UITableViewControllers with a UISearchDisplayController attached. If I simulate a memory warning in the iPhone simulator, whatever views are not active get dumped, and when I tap on the tab for one of these views with the searchDisplayController, NSZombieEnabled tells me -[UISearchDisplayController retain]: message sent to deallocated instance.

Here's my -didReceiveMemoryWarning:

- (void)didReceiveMemoryWarning
{
    [(PahAppDelegate *)[[UIApplication sharedApplication] delegate] saveContext];
    // Release any cached data, images, etc that aren't in use.
    self.searchWasActive = [self.searchDisplayController isActive];
    self.savedSearchTerm = [self.searchDisplayController.searchBar text];
    self.savedScopeButtonIndex = [self.searchDisplayController.searchBar selectedScopeButtonIndex];

    self.fetchedResultsController.delegate = nil;
    self.fetchedResultsController = nil;
    self.searchFetchedResultsController.delegate = nil;
    self.searchFetchedResultsController = nil;

    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
}

My best guess is that the UITableViewController dumps the subviews as well, and for whatever reason, it's not re-creating them when I go back to the other tabs. Since all of that functionality is built in Storyboard, I'm not quite sure how to go about requesting it re-load the searchDisplayController in question.

Note: I've never seen the app do this in the real world on the device (and neither have my beta testers), but I don't want Apple to refuse approval of the app because of this; plus fixing it seems like The Right Thing to Do.

searchDisplayController is a readonly property, so I'm not sure what tack to take to get things loaded like they should be.

È stato utile?

Soluzione

This definitely seems like a, possibly Storyboards, bug. As mentioned here: UISearchDisplayController causes crash after viewDidUnload, a brand new project using Storyboards and a UISearchDisplayController can reproduce this without even connecting an outlet for the UISearchDisplayController into your controller. The suggestion in that thread seems sane, create the UISearchDisplayController in code. I can't vouch for the workaround as I didn't test it, but I was curious and did reproduce the new project = crash claim and saw the exact same thing.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top