Xcode 新建iOS13以下项目(OC、Swift)

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;
}

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值