ios - TabBar 在程序化 segue 时消失

标签 ios swift

enter image description here我想以编程方式转到新的 ViewController,但是当我这样做时,我的 tabBar 消失了。

 if user == usernameStored && pass == passwordStored{
        print("Good")
        let vc = self.storyboard?.instantiateViewController(withIdentifier: "home")
        self.present(vc!, animated: true, completion: nil)



    }

最佳答案

从您的代码来看,这不是以编程方式进行的 segue。实际上,您在现有的任何内容之上呈现 一个viewController。因此 tabBarController 被覆盖了。

要在代码中使用segue,应该是这样的。 - homeSegueID 是您在 Storyboard中创建 segue 时提供的 identifier

performSegue(withIdentifier: "homeSegueID", sender: nil)

如果您只是想在没有 segue 的情况下以编程方式执行此操作,则可以改为执行此操作。 (假设您当前的 ViewController 位于 UINavigationController 堆栈中。

navigationController?.pushViewController(vc, animated: true)

关于ios - TabBar 在程序化 segue 时消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43349615/

相关文章:

ios - 导致 EXC_BAD_ACCESS 的 NSURLSession

iphone - 如何在通用 UIViewController - Universal App 中仅为 iPAD 创建 IBOutlet

ios - 如何使用 XCode 6.4 下载和替换 AppGroup 容器

c# - youtube 嵌入 iframe 黑盒

ios - 在 Swift 中记录 CLLocationPoints 时不准确

ios - 快速返回 GPS 位置的实用程序类?

iphone - 覆盖-(无效)setBackgroundImage :(UIImage *)image forState:(UIControlState)state for nib

ios - 核心数据 UML 图思维模式

ios - 快速从日期选择器获取日期

ios - Swift(解析)顶部 UITableViewCell 的新行?