ios 使用xcode11 新建項目工程的步驟詳解
xcode11新建項目工程,新增了scenedelegate這個類,轉(zhuǎn)而將原Appdelegate負(fù)責(zé)的對UI生命周期的處理擔(dān)子接了過來。故此可以理解為:ios 13以后,Appdelegate負(fù)責(zé)處理App生命周期,scenedelegate負(fù)責(zé)處理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導(dǎo)航條控制器 UITabBarController *tabControl = [[UITabBarController alloc] init]; tabControl.tabBar.barStyle = UIBarStyleBlack; //2.創(chuàng)建相應(yī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導(dǎo)航條控制器設(shè)為window根控制器 self.window.rootViewController = @[nav, nav2]; //顯示window [self.window makeKeyAndVisible]; }
2.如果要適配iOS 13以下的設(shè)備,需要把相關(guān)的scenedelegate刪掉才能正常使用。分四個步驟:
第一步: 刪除 Info.plist 里面的 SceneDelegate 配置信息
第二步:刪除 SceneDelegate 類文件
第三步:還原 AppDelegate 的 UIWindow 屬性。
第四步:刪除 AppDelegate.m 中的方法
至此,可以像往常一樣在 AppDelegate類中的 didFinishLaunchingWithOptions 方法中寫UI 執(zhí)行代碼。
總結(jié)
到此這篇關(guān)于ios 使用xcode11 新建項目工程的步驟詳解的文章就介紹到這了,更多相關(guān)ios xcode11 新建項目工程內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. JSP 中response.setContentType()的作用及參數(shù)2. idea開啟代碼提示功能的方法步驟3. ASP.NET MVC使用jQuery的Load方法加載靜態(tài)頁面及注意事項4. Docker究竟是什么 為什么這么流行 它的優(yōu)點和缺陷有哪些?5. ASP.NET MVC實現(xiàn)城市或車型三級聯(lián)動6. Springboot集成jsp及部署服務(wù)器實現(xiàn)原理7. IntelliJ IDEA 2020常用配置設(shè)置大全(方便干活)8. SSM框架JSP使用Layui實現(xiàn)layer彈出層效果9. IntelliJ IDEA設(shè)置條件斷點的方法步驟10. IntelliJ IDEA導(dǎo)入jar包的方法
