第1、首先要保證你的xcode是最新的囉嗦幾句:上週吧,咱們Xcode更新到了11.0,有的人可能尚未發現,新建的項目中多了一個場景代理類目#import "SceneDelegate.h",至於怎麼用的,我目前尚未定論。大家能夠嘗試一下,新建一個項目工程,在ViewController裏面寫一個按鈕buton渲染界面,用真機調試一下,再用模擬器調試一下,手機調試會出現黑屏,模擬器呢,會出現button按鈕,如今公司項目都是以前寫好的,可能不會存在這樣問題。下面就一一看下問題xcode
做爲一個開發人員,有一個交流學習的圈子是很重要的。如今小編這邊有一個學習交流羣(810733363)。歡迎你們進入交流學習。
bash
1、解決辦法一(以失敗了結)在AppDelegate引入session
#import "AppDelegate.h"
#import "ViewController.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 測試寫一下 沒有效果 我寫的兩個波浪沒有了
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
ViewController *home = [[ViewController alloc] init];
_navController = [[UINavigationController alloc] initWithRootViewController:home];
[_navController.navigationBar setBackgroundColor:[UIColor blueColor]];
[self.window setRootViewController:_navController];
// self.window.rootViewController = home;
[self.window makeKeyAndVisible];
// 添加這個運行以後會報錯
return YES;
}
複製代碼
這個方法第一件想到要加上的,但是不行,解決辦法是不行的畢竟剛出啦,有沒有相關的說明及解釋,若是有哪位iOS大神知道的,能否指點小弟一二,不勝感激
2、遇到的場景代理類目#import "SceneDelegate.h"app
#import <UIKit/UIKit.h>
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate>
@property (strong, nonatomic) UIWindow * window;
@end
複製代碼
#import "SceneDelegate.h"
@interface SceneDelegate ()
@end
@implementation SceneDelegate
- (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`.
// 使用此方法可選地配置並將UIWindow ' window '附加到提供的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).
// 這個委託並不意味着鏈接的場景或會話是新的(請參見「application:configurationForConnectingSceneSession」)。
}
- (void)sceneDidDisconnect:(UIScene *)scene {
// Called as the scene is being released by the system.
// 當場景被系統釋放時調用。
// This occurs shortly after the scene enters the background, or when its session is discarded.
// 這發生在場景進入後臺後不久,或者當它的會話被丟棄時。
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// 釋放與此場景關聯的任何資源,這些資源能夠在下一次場景鏈接時從新建立。
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
// 場景稍後可能從新鏈接,由於它的會話沒有必要被丟棄(請參見「application: diddiscardscenes」)。
}
- (void)sceneDidBecomeActive:(UIScene *)scene {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
- (void)sceneWillResignActive:(UIScene *)scene {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
- (void)sceneWillEnterForeground:(UIScene *)scene {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
- (void)sceneDidEnterBackground:(UIScene *)scene {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
@end
複製代碼
有道翻譯了下,仍是不會用,腦殼有瑕疵啊,哎,有大佬會用的能夠評論裏指點一二,拜謝!!!!!ide
來源:本文爲第三方轉載,若有侵權請聯繫小編刪除。學習