【iOS】applicationWillEnterForegro

2015-10-20  本文已影响633人  刘大帅

问题

最近在解决一个需求的时候,发现App由后台进入前台(applicationWillEnterForeground:),present一个视图的时候,没有了模态的动画,但是在applicationDidBecomeActive:中没有问题.

解决

据我调查,App由后台进入前台的时候,需要加载OpenGl的上下文环境,这需要时间.

Don't call it in AppDelegate::applicationWillEnterForeground. Because OpenGL context will be lost when enter to background. At this time OpenGL context may not be re-create by Android system. So, please do the operation after it is totally enter foreground.

所以解决方法就是要在加载时间上下工夫,比如,在模态之前sleep一段时间,或者,如果需求允许,在applicationDidBecomeActive:(这个方法在applicationWillEnterForeground:之后执行)中模态.

上一篇 下一篇

猜你喜欢

热点阅读