开发者

Parent ViewController deallocated upon memory warning

开发者 https://www.devze.com 2023-03-16 10:00 出处:网络
I have a MainViewController, from which a new VideoPageViewController is presented modally. In the ViewPageViewController, it will load a web page and launch the video, which is a heavy operation and

I have a MainViewController, from which a new VideoPageViewController is presented modally. In the ViewPageViewController, it will load a web page and launch the video, which is a heavy operation and sometimes causes memory warning. When it is ready to return to the MainViewController by dismissModalVie开发者_高级运维wController, it says the MainViewController is already deallocated! The app thus crashes.

This happens sometimes, but not always.

Is there any exception handling I can take on it? Can I recreate the parent view controller? HELP!

Thanks


Just retain the MainViewController so it's not released when that happens.

You can probably do that in your application delegate, or in the class that owns it.

Remember to release it when/if you are done using it, so it's properly disposed of.

0

精彩评论

暂无评论...
验证码 换一张
取 消