退出应用程序后隐藏用户界面 [英] Hide UI after resigning application
问题描述
问题如下:
我的应用可以使用密码保护.当用户按下主页按钮时,应用程序退出非活动状态.重新打开后,应用程序显示输入密码"屏幕.但是在显示之前,会先看到初始内容屏幕.同样,如果在按下主页按钮之后用户进入预览模式(两次按下主页按钮),则预览显示的是内容屏幕,而不是密码屏幕.
My app can be protected with a password. When the user presses home button, application resigns inactive. After reopening it, app shows "enter password" screen. But before it shows up, the initial content screen is visible for a moment. Also if, after pressing home button, user enters preview mode (home button double pressed), preview shows content screen, not password screen.
所以这是两个问题:
- 如何在应用程序被辞职前将UI(更改为密码屏幕或某些占位符)更改为UI,以便在预览模式下用户将看到内容屏幕以外的其他内容.
- 当应用程序再次激活时,如何使应用程序暂时不显示内容屏幕(在密码屏幕之前).
感谢您的帮助.
推荐答案
来自 移至后台该怎么做
应用程序可以使用其applicationDidEnterBackground:方法进行准备移至背景状态.移至后台时,所有应用程序应执行以下操作: Apps can use their applicationDidEnterBackground: method to prepare
for moving to the background state. When moving to the background, all
apps should do the following: 因此,在您的 So, in your 更新经过更多研究,结果发现您无法提供视图控制器-您只能影响根窗口.我已经在此答案中测试了该解决方案- Display一个视图或初始屏幕,位于applicationDidEnterBackground之前(以避免活动视图屏幕截图),它可以正常工作-因此,您可以创建一个显示登录屏幕的图像并将其放在用户界面的顶部. Update After a bit more research, it turns out you can't present a view controller - you can only affect the root window. I have tested the solution in this answer - Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot) and it works - So you can create an image that shows your login screen and put that over the top of your UI. 这篇关于退出应用程序后隐藏用户界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
applicationDidEnterBackground
方法中,您应该隐藏主视图并显示登录"视图.applicationDidEnterBackground
method you should hide your main view and present your 'login' view.