iOS 13
Somente se o alvo for 13 ou superior.
SceneDelegatenão é suportado antes do iOS 13 . Se você deseja usar SceneDelegatee também deseja oferecer suporte ao iOS anterior ao iOS 13 , é necessário adicionar algumas alterações ao seu projeto.
- Adicione o atributo de disponibilidade a toda a classe no arquivo SceneDelegate.swift .
@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
...
}
- O arquivo AppDelegate.swift possui dois novos
SceneDelegatemétodos. Adicione o atributo de disponibilidade a eles também.
@available(iOS 13.0, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
...
}
@available(iOS 13.0, *)
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
...
}
- Por fim, adicione um
UIWindowobjeto no AppDelegate.swift .
class AppDelegate: UIResponder, UIApplicationDelegate {
//Add this line
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
...
}
iOS 12 e versões anteriores
AppDelegateprecisa de uma UIWindowpropriedade. O iOS 13 usa SceneDelegateem novos projetos. Especifique o UIWindowobjeto e remova o arquivo SceneDelegate.swift .
Se você removeu o SceneDelegateprojeto, remova o dicionário Application Scene Manifest do Info.plist .
