美文网首页
Xcode新建 iOS13.0一下的项目记录

Xcode新建 iOS13.0一下的项目记录

作者: 茗记西岭雪 | 来源:发表于2020-09-30 10:17 被阅读0次

https://blog.csdn.net/u010733679/article/details/104814273

https://www.xugj520.cn/archives/xcode-swift.html

1.新建项目

2.解决ios13以下运行闪退问题

1)删除SceneDelegate.swift

官方文档:
In iOS 13 and later, use UISceneDelegate objects to respond to life-cycle events in a scene-
based app.

这个场景呢,如果不使用ipad的多窗口就不建议使用
2)删除 Main.storyboard,不使用storyboard布局,打开info.plist,删除Main storyboard file base name和Application Scene Manifest选项。

3)删除appdelegate 中关于scene的2个代理

4)appdelegate中添加根导航

//swift

class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        let screen = UIScreen.main.bounds        //获得设备尺寸
        self.window = UIWindow.init(frame: screen) //给“输出窗口“实例化并设置frame
        let viewController = ViewController() //实例化一个ViewController
        let navigationController = UINavigationController(rootViewController: viewController)  //为ViewController设置一个导航栏
        self.window?.rootViewController = navigationController//将“输出窗口”的根视图设置为导航栏
        self.window?.makeKeyAndVisible()       //  设置"输出窗口可见"
        return true
    }
}

//OC

@interface AppDelegate ()<UISplitViewControllerDelegate>
    @property (strong, nonatomic) UIWindow *window;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc]init];
    self.window.frame = [UIScreen mainScreen].bounds;
    LogInViewController *loginVC = [[LogInViewController alloc]initWithNibName:@"LogInViewController" bundle:nil];
    self.window.rootViewController = loginVC;
    [self.window makeKeyAndVisible];
    return YES;
}

相关文章

网友评论

      本文标题:Xcode新建 iOS13.0一下的项目记录

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