美文网首页
Xcode11 清除SceneDelegate和ContentV

Xcode11 清除SceneDelegate和ContentV

作者: 晴朗Nic | 来源:发表于2020-07-06 11:29 被阅读0次

    在Xcode11新建项目发现多出了SceneDelegate和ContentView两个文件,要使得变成基础版的模式就要做一下几个步骤带回大家找回熟悉感觉:

    1、选中info.plist文件把Application Scene Manifest删除如图下:

    1594005277198.jpg

    2、把项目中SceneDelegate.Swift和ContenView.swift删除如图下:

    1594005361447.jpg

    3、把AppDelegate.swift中的两个方法去掉如图下:

    Delegates.jpg

    4、首先自定义一个继承自UIViewController的RootViewController然后在AppDelegate里设置入口如下:

    Swift
    import UIKit
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        /// 主窗口
        var window: UIWindow?
    
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            // Override point for customization after application launch.
            self.window = UIWindow.init(frame: UIScreen.main.bounds)//UIScreen.main.bounds
            let rootVC = RootViewController()
            self.window?.backgroundColor = .orange
            self.window?.rootViewController = rootVC
            self.window?.makeKeyAndVisible()
            return true
        }
    }
    
    OC
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (nonatomic, strong) UIWindow *window;
    
    @end
    
    #import "AppDelegate.h"
    #import "ViewController.h"
    
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        ViewController *viewVC = [[ViewController alloc] init];
        self.window.rootViewController = viewVC;
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    @end
    
    
    

    相关文章

      网友评论

          本文标题:Xcode11 清除SceneDelegate和ContentV

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