/// 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
网友评论