Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

makeKeyWindow vs makeKeyAndVisible

What is the difference between makeKeyWindow and makeKeyAndVisible which are two methods of UIWindow ?

When will a UIWindow be a keyWindow but will not be visible?

like image 693
allenlinli Avatar asked Aug 12 '14 09:08

allenlinli


People also ask

What is makeKeyAndVisible?

makeKeyAndVisible()Shows the window and makes it the key window.

What is window in Swift?

Windows work with your view controllers to handle events and to perform many other tasks that are fundamental to your app's operation. UIKit handles most window-related interactions, working with other objects as needed to implement many app behaviors.


1 Answers

Each UIWindow has a windowLevel. A window is displayed in front of each window with a lower level, and behind each window with a higher level.

But what about two windows with the same level? The window whose level was set more recently is in front, by default. (“When a window enters a new level, it’s ordered in front of all its peers in that level.”) The makeKeyWindow message makes a window key, but that window might be partially or completely hidden behind another window on the same level. The makeKeyAndVisible message makes a window key, and moves it to be in front of any other windows on its level.

like image 160
rob mayoff Avatar answered Oct 12 '22 23:10

rob mayoff