如何在 applicationDidBecomeActive 之前更新屏幕?
当用户通过将应用程序切换到前台来激活应用程序时,我需要隐藏屏幕上的某些内容。
我尝试在 applicationDidBecomeActive 或 applicationWillEnterForeground 中插入代码,尽管它运行正常,但旧屏幕上会暂时显示我想要隐藏的文本。
如何在屏幕重绘之前隐藏该字段?
谢谢伊帕奥
I need to hide something on the screen when the user has activates the application by switching it to the foreground.
I have tried inserting my code within applicationDidBecomeActive or applicationWillEnterForeground and although it runs OK the old screen with the text I want to hide is displayed momentarily.
How can I hide the field before the screen is redrawn?
Thanks
iphaaw
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为问题是,iOS会在你的应用程序进入后台时捕获屏幕截图,因此动画会立即生效。
我认为做到这一点的唯一方法是在应用程序进入后台时隐藏/覆盖您的视图。
I think the problem is, iOS will capture a screenshot from your app in the moment it goes to the background, so the animation will work in an instant.
The only way in my opinion to do this is to hide / cover your view in moment the app goes to the background.
在
applicationWillResignActive:
中编写一些代码来“隐藏”您需要隐藏的任何内容。Write some code in
applicationWillResignActive:
to 'hide' whatever you need to hide.我遇到了类似的情况,但我不想隐藏,而是想显示一个块代码屏幕来授予访问权限。无论如何,我认为该解决方案也适用于您的需求。
我经常在我的 iOS 应用程序中实现自定义基本视图控制器。因此,我设置此视图控制器来侦听等效通知,而不是处理
applicationDidBecomeActive:
或applicationWillResignActive:
:I faced a similar situation but, instead of hiding, I wanted to show a block code screen to grant access. Anyway I think that the solution also applies to your needs.
I often implement a custom base view controller in my iOS applications. So instead of dealing with
applicationDidBecomeActive:
orapplicationWillResignActive:
I setup this view controller to listen for the equivalent notifications: