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?
The UIApplicationDelegate
usually has a reference to the "main window":
[[[UIApplication sharedApplication] delegate] window];
Furthermore, UIApplication
has an array of windows [[UIApplication sharedApplication] windows]
.
See the UIApplication Class Reference.