makeKeyWindow vs makeKeyAndVisible
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.
UIWindow makeKeyWindow: versus makeKeyAndVisible:
Each method maps to the selector of the same name makeKeyAndVisible
and makeKeyWindow
.
Or could it be that the method was incorrectly bound in (previous) MonoTouch versions?
GIT history shows (me ;-) that both never changed since they were first added (more than two years ago).
Documentation about the former states:
You can also hide and reveal a window using the inherited hidden property of
UIView
.
Maybe this happens in your code (or even within the iOS code).
makeKeyAndVisible & makeKeyWindow - uiwindow in iphone
The key window is the window which will receive user interaction.
You might take a look at this:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/WinPanel/Concepts/ChangingMainKeyWindow.html
Examples where makeKeyAndVisible is not required for UIWindow
An app can have more than one window. The call to makeKeyAndVisible
is used to specify which one is current.
Despite the fact that most apps only have one window, there is no way to assume that your primary window is to be the key window. Therefore you must explicitly call makeKeyAndVisible
.
iOS 5 UIWindow makeKeyAndVisible closes modal
I got the same behaviour, and as documentation states that makeKeyAndVisible
method is a convenience method it seems to me legit to substitute makeKeyAndVisible
call with working code:
[window makeKeyWindow];
window.hidden = NO;
Have no idea what's wrong, but it looks like a bug.
How to resolve: 'keyWindow' was deprecated in iOS 13.0
This is my solution:
let keyWindow = UIApplication.shared.connectedScenes
.filter({$0.activationState == .foregroundActive})
.compactMap({$0 as? UIWindowScene})
.first?.windows
.filter({$0.isKeyWindow}).first
Usage e.g.:
keyWindow?.endEditing(true)
Related Topics
Get Index or Tag Value from Imageview Tap Gesture
How to Calculate Current Location in Watchkit Extension
Property 'Self.*' Not Initialized at Super.Init Call
Open an External Link in Safari (Cordova)
How to Default Uilabel Font and Size Using Swift
What Is the Use of Singleton Class in Objective-C
Collectionview Duplicate Cell When Loading More Data
Get Created Date and Last Login Date from Firuser with Firebase 3
Fit Image of Random Size into a Uiwebview (Ios)
How to Access User Defined Runtime Attribute from the 'Sender' Object
Ios- Check Whether Current Time Is Between Two Times or Not
How to Code the Launchscreen Programmatically
Understanding Model-View-Controller
How to Detect "Clear" Notifications