0

I have an iPad SplitViewController application with the following features:

  • master (left hand) view controller is hidden in both portrait and landscape by returning YES in the shouldHideViewController delegate method
  • master view controller contains a tab bar controller
  • I utilise a multiple master detail manager to manage swapping the detail view controller based upon the selection made by the user in the master tab bar

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.

4

1 回答 1

2

我向 Apple 技术支持提出了这个问题。他们的答复如下:

对雷达的搜索表明这是 iOS 5.1 中的一个已知问题,并且工程部门已经意识到了这一点。目前,除了确保您没有收到内存警告外,似乎没有解决此问题的方法。

如果您愿意,可以在 http://bugreporter.apple.com/提交其他错误。此外,我建议您尝试一下,看看它在 iOS 6 中是否仍然存在问题。如果是,请提交错误并将雷达编号发送给我,以便我跟踪它。

我按照他们的建议做了,并在 iOS 6 中进行了尝试。我发现问题没有出现,因此似乎在 iOS 6 中得到了修复。Apple 没有为 iOS 5.1 提供解决方案。

于 2012-08-29T01:47:47.000 回答