[英]Swift 5 iOS13 - Segue to another Storyboard or unconnected View Controller without creating Card View
keyWindow
在 iOS 13 中也被棄用,因此我為這個問題找到了另一個解決方案。
隨着當前 Swift 5.1、iOS 13 和 Xcode 11 的更新,下面的代碼在使用時會創建“卡片視圖”,以便用戶輕松滑動查看之前的內容。 然而,問題在於,如果用戶在使用下面的代碼時登錄或注銷,則用戶在注銷后可以返回登錄屏幕或主應用程序,這是有問題的。 在故事板或未連接的視圖控制器之間將用戶分隔到不創建“卡片視圖”的最佳方法是什么? “解決方案”的問題是keyWindow
已被棄用。 它可以工作但正在尋找官方解決方案。
在故事板和未連接的視圖控制器之間進行切換的舊方法
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Start")
self.present(vc, animated: true, completion: nil)
解決方案
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "homeVC") as! UITabBarController
UIApplication.shared.keyWindow?.rootViewController = vc
如果您真的喜歡“舊方式”,請繼續使用它,但添加一行將vc
的modalPresentationStyle
設置為.fullScreen
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.