第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
来源:本文为第三方转载,若有侵权请联系小编删除。学习