[[UIApplication sharedApplication] delegate].window

The window the application is expected to use.

This property contains the window used to render the visual content of the application on the device’s home screen.

[UIApplication sharedApplication].keyWindow

The window currently being displayed on the device. This is usually your application’s window, but it could be a system window.

This property holds the UIWindow object in the Windows array that recently sent the makeKeyAndVisible message.


[UIApplication sharedApplication]. KeyWindow will be affected by UIActionSheet. Whenever an actionSheet pops up anywhere, the page dies and cannot continue. Or if your app needs to jump to another app and then go back to the same app, it might cause the UI to mess up, because that would be like adding a new window as keyWindow and returning with a different window. Although apple says it fixed the problem in ios8, it will still happen in 9.2

Therefore, it is recommended more often

[[UIApplication sharedApplication] delegate].window
Copy the code