通过多任务处理重新加载修改后的视图
这个问题是另一个问题的结果,其中我不知道如何通过多任务处理从设置包中更新 NSUserDefaults 。现在我这样做了(感谢@mvds),将refreshDefaults代码放置在应用程序委托内的applicationWillEnterForeground中。
问题是,代码意味着视图中的更改(背景颜色等),因此当我在更改设置后返回应用程序时,会显示视图,然后才调用 applicationWillEnterForeground。
也就是说,它显示了以前的“主题”,然后又变成了新的“主题”。有什么方法可以克服这个问题,在应用程序显示之前通知更改?结果很丑陋,我只是在 lyfecicle 中没有看到任何以前可能调用的方法。
This question is a result of another one in which i didn't knew how to update NSUserDefaults from a Settings bundle with multitasking. Now i do (thanks to @mvds), placing the refreshDefaults code inside the app delegate, in applicationWillEnterForeground.
The problem is, the code implies a change in the view (background color, etc) so when i come back to the app after changing the setting, the view is displayed and only afterwards is called applicationWillEnterForeground.
This is, it shows the previous "theme" and then it changes to the new one. Is there any way to overcome this, to notify of the change before the app gets displayed? The result is ugly and i just don't see any method in the lyfecicle that might be called before.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当应用程序进入后台模式时,系统会截取当前状态的屏幕截图。当应用程序返回前台时,它首先在加载应用程序时显示此屏幕截图。
如果您更改主题颜色,您首先看到的是此屏幕截图,然后显示并更新视图。您无法更改此行为。
您唯一能做的就是尝试在
WillEnterBackground
方法中显示不同的内容,例如空 UI 或闪屏。When an app is going in background mode, the system take a screenshot of the current state. When the app is comming back in foreground, it is first displaying this screenshot while loading back the application.
If you change your theme colors, what you see in the first place is this screenshot, and then the view is displayed and updated. You can not change this behaviour.
The only thing you can do is try to display something different in the
WillEnterBackground
method, like an empty UI or a splashscreen.