iosipaduisplitviewcontrollermemory-warning

iPad SplitViewController Memory Warning Causes Problems With Master View


I have an iPad SplitViewController application with the following features:

I have a problem that only occurs after a memory warning is received by the application. When the master view slides in (either via a swipe or tapping the left bar button) the view appears effectively empty i.e. it does not contain any table view, just the semi-transparent background where the table view should be. If I tap the other view in my tab bar it loads it's master view correctly. If I then tap back to the problem view it now appears correctly.

Originally I had another problem in that not only was the view empty but it was also sized for full screen. I was able to fix the size problem via the solution proposed in this SO question - it is noted in the solution that "Apparently when a memory warning is received, the view controller gets released, so when it presents itself again, it gets it's size from it's parent view, which is full screen. So you just have to reset the frame every time it gets loaded."

By putting break points in my code I can verify that when I first try to access the master view after a memory warning the ViewDidLoad event is called (this does not occur if there has not been a memory warning), however the ViewDidAppear & ViewWillAppear events are not called. So the app is aware that it needs to reload the master view after a memory warning, but for some reason it does not seem to show the master view.

I'm struggling to work out how to correctly make the view appear again after a memory warning. Or is there something I should be doing to prevent the master view from being unloaded when a memory warning is received?

UPDATE: I have also observed that if the master view is showing at the time of the memory warning then this problem does not occur.


Solution

  • I raised this issue with Apple technical support. Their reply was as follows:

    A search of radar shows that this is a known problem in iOS 5.1 and that engineering is aware of it. At the moment there does not seem to be a workaround for this problem other than making sure that you don't get memory warnings.

    If you'd like you can file an additional bug at: http://bugreporter.apple.com/. Additionally I'd suggest that you try this and see if it is still an issue in iOS 6. If it is please file a bug and send me the radar number so that I can keep track of it.

    I did as they suggested and tried it out in iOS 6. I found that the problem did not occur and therefore seems to be fixed in iOS 6. Apple did not offer a solution for iOS 5.1.