AppDelegate启动界面 判断是否为第一次启动

/// Mark: - 跳转时调用storyboard才会显示sotryboard上建的界面,否则为纯代码形式!


var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

window?.makeKeyAndVisible()

/// 得到当前应用的版本号

let infoDictionary = Bundle.main.infoDictionary

let currentAppVersion = infoDictionary!["CFBundleShortVersionString"] as! String

/// 取出之前保存的版本号

let userDefaults = UserDefaults.standard

let appVersion = userDefaults.string(forKey: "appVersion")

let storyboard = UIStoryboard(name: "Main", bundle: nil)

/// 如果 appVersion 为 nil 说明是第一次启动;如果 appVersion 不等于 currentAppVersion 说明是更新了

if appVersion == nil || appVersion != currentAppVersion {

/// 保存最新的版本号

userDefaults.setValue(currentAppVersion, forKey: "appVersion")

let guideViewController = storyboard.instantiateViewController(withIdentifier: "GuideViewController") as! GuideViewController

self.window?.rootViewController = guideViewController

}else {

///Mark: -  调用storyboard才会显示界面,否则为纯代码形式!

let tabBarController =  storyboard.instantiateViewController(withIdentifier: "TabBarController") as! UITabBarController

}

///Mark: -  调用storyboard才会显示sotryboard上建的界面,否则为纯代码形式!

//            let storyboard = UIStoryboard(name: "Main", bundle: nil)

//            let tabBarController =  storyboard.instantiateViewController(withIdentifier: "TabBarController") as! UITabBarController

//            self.window?.rootViewController = tabBarController

return true

}

原文GitHub地址:https://github.com/GuiminChu/JianshuExample/blob/master/CustomPresentationViewController/CustomPresentationViewController/CustomPresentationController/CustomPresentationController.swift

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • iOS 实战开发课程笔记 本贴旨在作为对极客班 《iOS 开发实战》第五期期课程视频重新学习的笔记。目标是建立一个...
    黄穆斌阅读 3,105评论 12 57
  • 1.自定义控件 a.继承某个控件 b.重写initWithFrame方法可以设置一些它的属性 c.在layouts...
    圍繞的城阅读 3,494评论 2 4
  • 接着上一篇 开始用Swift开发iOS 10 - 24 使用TestFlight进行Beta测试 ,这一篇学习使用...
    Andy_Ron阅读 1,342评论 0 4
  • 遇见《姥姥语录》是初三那年,从同学那里借回家,和妈妈一起看完。当时的感觉就是这本书很有意思,觉得倪萍的姥姥是一个有...
    海北__阅读 620评论 0 0
  • 前端与后台交互: JSON: 1、JSON不是一个单独的数据类型,它只是一种特殊的数据格式,它是对象数据类型的 2...
    gaoqizhuhui阅读 286评论 0 0