redraw GUI on didreceivelocalnotification when come from lock screen iphone

有些话、适合烂在心里 提交于 2019-12-01 22:20:34

问题


How do I prevent my GUI from redraw when it comes back from lock screen after receiving a UILocalNotification? In didReceiveLocalNotification I present a modal view, but the old state of my view controllers is shown for a moment before that. How do I prevent this?

Also the order of events I get when I come back on local notification from background is as following:

1. UIApplicationWillEnterForegroundNotification
2. UIApplicationDidBecomeActiveNotification
3. didReceiveLocalNotification

When I come from lock screen:

1. didReceiveLocalNotification
2. UIApplicationDidBecomeActiveNotification

Why is this difference and whether there is something else I'm missing?

Thanks


回答1:


Here's how it was solved. May be it's not the way, but it worked for me. Since my application is voip/audio, it doesn't come to didFinishLaunchingWithOptions... I found out, that iOS uses a cached image from a previous state for animation when it resumes from background or from sleep mode. So the solution is basically to exchange this cached image with my default.png image. I do it in applicationWillResignActive delegate. There I add a modal view with a Default.png picture and dismiss it in applicationDidBecomeActive. This is really in short. Hopefully it will help somebody else with the same problem.




回答2:


You can provide a custom image that is displayed when launching/resuming from a local notification. Simply set the alertLaunchImage property on your local notification to the name of the correct image.

From the Docs:

The string is a filename of an image file in the application bundle. This image is a launching image specified for a given notification; when the user taps the action button (for example, “View”) or moves the action slider, the image is used in place of the default launching image. If the value of this property is nil (the default), the system either uses the previous snapshot, uses the image identified by the UILaunchImageFile key in the application’s Info.plist file, or falls back to Default.png.

alertLaunchImage



来源:https://stackoverflow.com/questions/5766090/redraw-gui-on-didreceivelocalnotification-when-come-from-lock-screen-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!