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)
'keyWindow' is deprecated: first deprecated in iOS 13.0 in Objective-C
You can use the window through AppDelegate class like..
BarcodeScannerVC * controller = [[BarcodeScannerVC alloc] initWithNibName:@"BarcodeScannerVC" bundle:[NSBundle mainBundle]];
//[self presentViewController:controller animated:YES completion:nil];
UIWindow * currentwindow = [[UIApplication sharedApplication] delegate].window;
[currentwindow.rootViewController presentViewController:controller animated:YES completion:nil];
Here i changed to get currentwindow line only so just change it.
UIWindow * currentwindow = [[UIApplication sharedApplication] delegate].window;
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
Alamofire Get API Request Not Working as Expected
Deinit Method Is Never Called - Swift Playground
How to Make a Weak Protocol Reference in 'Pure' Swift (Without @Objc)
Multiple Functions With the Same Name
Choosing Coredata Entities from Form Picker
How to Encode a String to Base64 in Swift
Swift Variable Name With ' (Backtick)
Swift 4 Decodable - Dictionary With Enum as Key
Wrong Specialized Generic Function Gets Called in Swift 3 from an Indirect Call
What Is the Purpose of Willset and Didset in Swift
The Use of Swift 3 @Objc Inference in Swift 4 Mode Is Deprecated
Nsurlsession Concurrent Requests With Alamofire
Nsdate Timeintervalsince1970 Not Working in Swift
Does Swift Have Documentation Generation Support
What Is Geometry Reader in Swiftui
Changing Navigation Title Programmatically
Xcode 8 Beta 3: Expected ',' Joining Parts of a Multi-Clause Condition