Advantages of SceneDelegate:- This is the result of new multi-window support feature that is introduced with iPad-OS. The UIScene API allows us to create multiple instances of our app's UI as separate instances in the application switcher.
Step 2: Delete the Storyboard Your new project has been created, now navigate to the left side of your interface, select the “Main. storyboard” file in the main folder, left-click and hit delete.
You need to do the following steps:
You also need to add var window:UIWindow?
if it is not present in AppDelegate
To add to accepted answer: you also need to write this in your AppDelegate:
self.window = UIWindow(frame: UIScreen.main.bounds)
let controller = MyRootViewController()
window?.rootViewController = controller
window?.makeKeyAndVisible()
It is a complete solution for empty project generated with Xcode (with storyboard)
SceneDelegate.swift
fileApplication Scene Manifest
from Info.plist
fileAppDelegate.swift
file
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window:UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
window?.makeKeyAndVisible()
return true
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With