mga
mga

Reputation: 1970

iPhone app: recover view after didReceiveMemoryWarning

The app in question has a MainView->ModalView pair. The ModalView is shown via UIModalTransitionStyleFlipHorizontal. In case of didReceiveMemoryWarning, MainView is dumped (since it is not visible) and the app stays "alive" but when you flip back there is a (very) short period of time when the screen is blank (since the modal dialog is returning to a now-deallocated view). When the animation transition is over, MainView is regenerated and all is ok.

I just would like to somehow regenerate MainView before returning from ModalView (in case of a memory warning).

Is this a good idea? Am I doing something wrong as far as the warning is concerned?

Thanks

Upvotes: 1

Views: 1083

Answers (2)

ambertch
ambertch

Reputation: 7649

You can also choose to ignore the memory warning by commenting out the section in DidReceiveMemoryWarning - do at your own risk though :)

Upvotes: 0

mahboudz
mahboudz

Reputation: 39376

You might want to try to reload your MainView, before you start the flip, so that there is no blank screen to wait for. That does mean that your flip will be delayed, but maybe that is better?

If you want to reload your MainView before you head to it, try to access MainView like this

if (MainView)
    ....

if the MainView is a view or like this

if (MainView.view)
    .....

if the MainView is a view controller. What the access of the view does is to force a reload of that view from the NIB, or loadView.

Upvotes: 1

Related Questions