美文网首页基础应用
使用xcode11新建工程问题

使用xcode11新建工程问题

作者: 摘心 | 来源:发表于2019-10-16 10:07 被阅读0次

使用xcode11新建工程,target选择iOS13以下版本,app启动黑屏。
处理方案:
swift :
在appdelegate 类添加window属性

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }
}

oc:
在appdelegate类中为window成员变量添加_window属性


@implementation AppDelegate

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
   
    if (@available(ios 13, *)) {

    } else {
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[MainViewController alloc]init]];
        self.window.rootViewController = nav;
        [self.window makeKeyAndVisible];
    }
   
    
    return YES;
}

iOS13系统window加载代码在ScreenDelegate文件中

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions  API_AVAILABLE(ios(13.0)){
    // 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).
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[MainViewController alloc]init]];
    self.window.rootViewController = nav;
    
    [self.window makeKeyAndVisible];
    
    
}

相关文章

网友评论

    本文标题:使用xcode11新建工程问题

    本文链接:https://www.haomeiwen.com/subject/xkjymctx.html