applicationDidBecomeActive 当前屏幕
如何确定 applicationDidBecomeActive 中当前的控制器/窗口?例如,在登录屏幕(这是一个 LoginViewController)上,如果 applicationDidBecomeActive 触发,我如何知道它是来自 appDelegate 的登录屏幕?
How can I determine what controller/window is currently in the applicationDidBecomeActive? For example on the login screen (which is a LoginViewController), if the applicationDidBecomeActive fires how do I know it is the login screen from the appDelegate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
传递给
applicationDidBecomeActive
的UIApplication
对象具有windows
属性。它是可见窗口的NSArray
,从后到前排序。一旦有了前台窗口,您就可以获取第一个子视图并测试其类型:
The
UIApplication
object passed toapplicationDidBecomeActive
has awindows
property. It is anNSArray
of visible windows, ordered back to front.Once you have the foreground window, you can get the first subview and test its type: