xcode11鏂伴」鐩垹闄ain.storyboard 涓ょ鏂规硶
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xcode11鏂伴」鐩垹闄ain.storyboard 涓ょ鏂规硶相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/not_2_run' title='not run'>not run load 鍥剧墖 OLE 浣跨敤 file 鑷繁 files initial
鏂规硶涓€
蹇冩€ョ殑绔ラ瀷鎸夌収鑰佹搷浣滃畬鎴愬悗鍐嶆寜鐓у涓嬫搷浣滃嵆鍙?/strong>
/** 寮冪敤storboard 1銆乮nfo.plist鍘婚櫎 <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <false/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>SceneDelegate</string> <key>UISceneStoryboardFile</key> <string>Main</string> </dict> </array> </dict> </dict> 2銆佸惎鍔ㄩ〉娉ㄩ噴 - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with. return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; } - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions { // Called when the user discards a scene session. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. // Use this method to release any resources that were specific to the discarded scenes, as they will not return. } */
鍏蜂綋濡備笅锛?/strong>
鐢▁code11鏂板缓iOS椤圭洰鍚庯紝鎯宠鍒犻櫎榛樿鐨刴ain.storyboard锛屼娇鐢ㄨ嚜瀹氫箟鐨剋indow鍜宑ontroller鐨勫潙銆?/p>
鍏锋湁涓€瀹氱粡楠岀殑浜烘兂蹇呴兘鐭ラ亾Xcode11涔嬪墠锛屾兂瑕佽揪鍒颁笂闈㈢殑鐩殑姝ラ鍚с€傞鍏堝氨鏄€変腑宸ョ▼鏂囦欢閫夐」锛屼箣鍚庡垹闄ain Interface閫夐」閲岀殑Main锛屽涓嬪浘锛?/p>
涔嬪悗鍦ˋppdelegate鐨刣idFinishLaunchingWithOptions鏂规硶涓嚜瀹氫箟window骞惰缃负keyWindow鍜岃瀹冩樉绀猴紝濡備笅鍥?
灏辫繖涔堢畝鍗曠殑瀹炵幇浜嗐€?/p>
鐒堕箙闅忕潃ios13鐨勬帹鍑猴紝鍦ㄤ箣鍓岮ppDelegate鐨勫熀纭€涓婂鍑轰簡涓€涓猄ceneDelegate锛屼細灏咥ppDelegate閲岀殑lifecycle鐨勯偅浜涗唬鐞嗘柟娉曡浆浜ょ粰SceneDelegate锛屽氨鏄€氳繃AppDelegate閲屼互涓嬩袱涓柟娉曞疄鐜扮殑
浠ヤ笅鐨勫唴瀹规槸鎽樿嚜鑻规灉瀹樻柟鏂囨。锛?/p>
Overview
A UISceneSession object manages a unique runtime instance of your scene. When the user adds a new scene to your app, or when you request one programmatically, the system creates a session object to track that scene. The session contains a unique identifier and the configuration details of the scene. UIKit maintains the session information for the lifetime of the scene itself, destroying the session in response to the user closing the scene in the app switcher.
You do not create session objects directly. UIKit creates sessions in response to user interactions with your app. You can also ask UIKit to create a new scene and session programmatically by calling the requestSceneSessionActivation:userActivity:options:errorHandler: method of UIApplication. UIKit initializes the session with default configuration data based on the contents of your app鈥榮 Info.plist file.
澶ф鎰忔€濆氨鏄紝涓€涓猆ISceneSession涓嶇敤浣犵洿鎺ュ幓鍒涘缓瀵硅薄锛屼綘鍙互鐢║IApplication閲岀殑requestSceneSessionActivation:userActivity:options:errorHandler:鏂规硶锛岃繖涓柟娉曚細甯綘鍒濆鍖栦竴涓熀浜巌nfo.plist鏂囦欢閲岀殑榛樿configuration鐨剆ession瀵硅薄銆?/p>
鍥犳xcode11涓瀹炵幇鑷繁鐨勬病鏈夐粯璁ain.storyboard鐨勯」鐩紝灏卞緱灏哠ceneDelegate閲岀殑lifecycle杞氦缁橝ppDelegate锛屾寜鐓т笂闈㈡墍璇达紝杩欎竴姝ユ搷浣滃氨鏄紝鍒犻櫎鎴栨敞閲婁竴涓嬫埅鍥鹃噷鐨勪袱涓柟娉?/p>
鎺ヨ繎鐫€鍒犻櫎鍦╥nfo.plist閲岀殑Application Scene Manifest鏉$洰
涔嬪悗灏辨槸xcode11浠ュ墠鐨勫父瑙勬搷浣滀簡锛岄鍏堬紝鍒犻櫎info.plist閲岀殑Main storyboard file base name鏉$洰
涔嬪悗鍦ˋppDelegate.swift閲屾坊鍔爓indow灞炴€э紝鍥犱负xcode榛樿鍒犻櫎浜嗚繖涓睘鎬э紝鐜板湪浣犻渶瑕佸皢瀹冮噸鏂版坊鍔犲洖鏉ユ墠琛岋紝濡傛灉鏄疧C鍐欑殑璇濓紝灏卞湪AppDelegate.h閲屾坊鍔犺繖涓獁indow灞炴€с€?/p>
涔嬪悗灏卞湪didFinishLaunch鏂规硶閲屽垵濮嬪寲self.window锛屽苟璁剧疆涓簁eywindow鍜岃瀹冩樉绀猴紝骞跺垵濮嬪寲榛樿鎺у埗鍣ㄥ嵆鍙€?/p>
鏈€鍚? 鍦⊿ceneDelegate.m涓坊鍔犳牴鎺у埗鍣?/p>
- (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 = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootVc = [[UIViewController alloc]init]; rootVc.view.backgroundColor = [UIColor purpleColor]; UINavigationController *rootNav = [[UINavigationController alloc]initWithRootViewController:rootVc]; [self.window setRootViewController:rootNav]; [self.window makeKeyAndVisible]; }
以上是关于xcode11鏂伴」鐩垹闄ain.storyboard 涓ょ鏂规硶的主要内容,如果未能解决你的问题,请参考以下文章