views:

370

answers:

2

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

+1  A: 

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.

mahboudz
Thanks for the answer. Since it is a modal dialog, I tried `if (self.parentViewController.view);` and then the code I have to flip back. It does not regenerate the view.
mga
I'm not sure if that is the same view. You've got your code, so you know better. Did you try just using if (MainView)?
mahboudz
Well I assume the view I should be asking for is the one that once called the modal view right? `self.parentViewController.view` would point there right?
mga
could self.parentViewController.view be nil since it was released? Check that with an NSLog before returning to MainView to see.
mahboudz
A: 

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

ambertch