手机h5免费模板网站模板,更合高明网站建设,上海建站推广公司,域名怎么创建网站在Xcode11前我们可以在AppDelegate的钩子didFinishLaunchingWithOptions进行自定义UIWindow对象。但是Xcode11后自定义UIWindow会报错无法启动APP。 是因为iOS13中AppDelegate的职责发生了改变#xff1a; iOS13之前#xff0c;AppDelegate全权处理App生命周期和UI生命周期 iOS13之前AppDelegate全权处理App生命周期和UI生命周期 iOS13之后AppDelegate的职责是 1、处理 App 生命周期 2、新的 Scene Session 生命周期 那UI的生命周期交给新增的Scene Delegate处理, AppDelegate不在负责UI生命周期所有UI生命周期交给SceneDelegate处理。所以我们需要在SceneDelegate的scene钩子进行自定义UIWindow初始化。 1.首先我们不仅要删除info.plist中的Main storyboard file base name还需要删除Application Scene Manifest下的Storyboard Name。具体看图 2.然后在 SceneDelegate 中进行初始化UIWindow.
// SceneDelegate.m- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {// Use this method to optionally configure and attach the UIWindow window to the provided UIWindowScene scene.// If using a storyboard, the window property will automatically be initialized and attached to the scene.// This delegate does not imply the connecting scene or session are new (see application:configurationForConnectingSceneSession instead).self.window [[UIWindow alloc] initWithWindowScene:(UIWindowScene* )scene];self.window.frame CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);// 初始化跟视图UIViewController* ROOTVC [[ViewController alloc] init];// 初始化层级导航控制UINavigationController* ROOTNavigation [[UINavigationController alloc]initWithRootViewController:ROOTVC];self.window.rootViewController ROOTNavigation;// 显示[self.window makeKeyAndVisible];
}
}