/// Mark: - 跳轉(zhuǎn)時(shí)調(diào)用storyboard才會(huì)顯示sotryboard上建的界面,否則為純代碼形式!
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window?.makeKeyAndVisible()
/// 得到當(dāng)前應(yīng)用的版本號(hào)
let infoDictionary = Bundle.main.infoDictionary
let currentAppVersion = infoDictionary!["CFBundleShortVersionString"] as! String
/// 取出之前保存的版本號(hào)
let userDefaults = UserDefaults.standard
let appVersion = userDefaults.string(forKey: "appVersion")
let storyboard = UIStoryboard(name: "Main", bundle: nil)
/// 如果 appVersion 為 nil 說明是第一次啟動(dòng);如果 appVersion 不等于 currentAppVersion 說明是更新了
if appVersion == nil || appVersion != currentAppVersion {
/// 保存最新的版本號(hào)
userDefaults.setValue(currentAppVersion, forKey: "appVersion")
let guideViewController = storyboard.instantiateViewController(withIdentifier: "GuideViewController") as! GuideViewController
self.window?.rootViewController = guideViewController
}else {
///Mark: -? 調(diào)用storyboard才會(huì)顯示界面,否則為純代碼形式!
let tabBarController =? storyboard.instantiateViewController(withIdentifier: "TabBarController") as! UITabBarController
}
///Mark: -? 調(diào)用storyboard才會(huì)顯示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