本文介绍了获取应用程序的主窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
UIApplication 有一个方法 keyWindow
,但是如果显示了一个警报视图,那么这将返回警报视图的窗口,而不是应用程序的主窗口.
UIApplication has a method keyWindow
, however if an alert view is showing then this returns the window of the alert view and not the main window of the application.
如何获取应用的主窗口?
How can I get the app's main window?
推荐答案
UIApplicationDelegate
通常有对主窗口"的引用:
The UIApplicationDelegate
usually has a reference to the "main window":
[[[UIApplication sharedApplication] delegate] window];
此外,UIApplication
有一个窗口数组 [[UIApplication sharedApplication] windows]
.
Furthermore, UIApplication
has an array of windows [[UIApplication sharedApplication] windows]
.
这篇关于获取应用程序的主窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!