gpt4 book ai didi

ios - Swift 5 iOS13 - 在不创建卡片 View 的情况下转到另一个 Storyboard或未连接的 View Controller

转载 作者:行者123 更新时间:2023-11-28 13:27:11 25 4
gpt4 key购买 nike

keyWindow 在 iOS 13 中也已弃用,因此我找到了解决此问题的另一种方法。

随着 Swift 5.1、iOS 13 和 Xcode 11 的当前更新,下面的代码在使用时会创建“卡片 View ”,因此用户可以轻松向下滑动并返回到之前的 View 。然而,问题在于,如果用户在使用下面的代码时登录或注销,用户可以在注销后返回登录屏幕或主应用程序,这是有问题的。在 Storyboard或未连接的 View Controller 之间将用户引导至不创建“卡片 View ”的最佳方式是什么? “变通解决方案”的问题是 keyWindow 已被弃用。它正在寻找官方解决方案。

在 Storyboard和未连接的 View Controller 之间进行 segue 的旧方法

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

最佳答案

如果您真的喜欢“旧方法”,请继续使用它,但添加一行将 vcmodalPresentationStyle 设置为 .fullScreen

关于ios - Swift 5 iOS13 - 在不创建卡片 View 的情况下转到另一个 Storyboard或未连接的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58151928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com