ios 使用xcode11 新建項目工程的步驟詳解
xcode11新建項目工程,新增了scenedelegate這個類,轉而將原Appdelegate負責的對UI生命周期的處理擔子接了過來。故此可以理解為:ios 13以后,Appdelegate負責處理App生命周期,scenedelegate負責處理UI生命周期的處理。
1.使用scenedelegate(iOS 13以下黑屏)
如果創(chuàng)建app支持的最低版本是ios13,可以考慮直接使用。
舉例使用系統(tǒng)底部欄:
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)){ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; //1.創(chuàng)建Tab導航條控制器 UITabBarController *tabControl = [[UITabBarController alloc] init]; tabControl.tabBar.barStyle = UIBarStyleBlack; //2.創(chuàng)建相應的子控制器(viewcontroller) ViewController *control = [[ViewController alloc] init]; control.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"first" image:[UIImage imageNamed:@"icon_contact_normal"] selectedImage:[UIImage imageNamed:@"icon_contact_normal"]]; UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController: control]; ViewController2 *control2 = [[ViewController2 alloc] init]; control2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"first" image:[UIImage imageNamed:@"icon_contact_normal"] selectedImage:[UIImage imageNamed:@"icon_contact_normal"]]; UINavigationController * nav2 = [[UINavigationController alloc]initWithRootViewController: control2]; //將Tab導航條控制器設為window根控制器 self.window.rootViewController = @[nav, nav2]; //顯示window [self.window makeKeyAndVisible]; }
2.如果要適配iOS 13以下的設備,需要把相關的scenedelegate刪掉才能正常使用。分四個步驟:
第一步: 刪除 Info.plist 里面的 SceneDelegate 配置信息
第二步:刪除 SceneDelegate 類文件
第三步:還原 AppDelegate 的 UIWindow 屬性。
第四步:刪除 AppDelegate.m 中的方法
至此,可以像往常一樣在 AppDelegate類中的 didFinishLaunchingWithOptions
方法中寫UI 執(zhí)行代碼。
總結
到此這篇關于ios 使用xcode11 新建項目工程的步驟詳解的文章就介紹到這了,更多相關ios xcode11 新建項目工程內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Drawer?Builder組件實現(xiàn)flutter側邊抽屜效果示例分析
這篇文章主要為大家介紹了Drawer?Builder組件實現(xiàn)flutter側邊抽屜效果示例分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-10-10UITableViewCell在編輯狀態(tài)下背景顏色的修改方法
這篇文章主要給大家介紹了關于UITableViewCell在編輯狀態(tài)下背景顏色的修改方法,文中通過示例代碼介紹的非常詳細,對大家具有一定的參考學習價值,需要的朋友們下面跟著小編一起來學習學習吧。2017-07-07