ios - 从 UIViewController 过渡到 TabBarViewController

标签 ios iphone swift uitabbarcontroller uiviewcontentmode

我已经寻找解决方案 6 个小时了,但没有找到适合我情况的解决方案。我的 Storyboard遵循以下流程:

TabBarViewController -> NavigationController ->TableViewController -> UIViewController(见下图)

Picture of StoryBoard

当单击最后一个 View Controller (陌生人 View Controller )中的“通知”按钮时,我想以编程方式从该 View Controller (陌生人 View Controller )转换/转换到 TabBarViewController 的不同子级(它是图中标题为“Look around”的 Controller )。

每次我执行传统的转场时:

  1. 选项+从陌生人 View Controller 中拖动segue --> 环顾四周 View Controller
  2. 给segue一个标识符
  3. 以编程方式使用 self.performSegueWithIdentifier。

我得到了一个过渡。但是“环顾四周”选项卡栏在 Storyboard中消失了,在模拟器中,一旦我点击“通知”, View 就会更改为“环顾四周” View ,但下面的选项卡栏并没有反射(reflect)这种变化,因为它仍然突出显示上一个选项卡。

我已经处理了 IBAction 函数中需要处理的所有其他处理。一旦用户点击“通知”,这只是正确地将用户发送到不同 View 的问题。

对此的任何指导将不胜感激。

如果您对我有任何问题或疑虑,请随时提出。我是新手,愿意接受任何帮助。

最佳答案

ViewController 是 NavigationBar 的子级,而 NavigationBarController 是 TabBarController 的子级。因此不需要 Segue,因为它会扰乱流程。

以编程方式尝试

@IBAction func notifyButtonTapped(sender: AnyObject) {
        tabBarController?.selectedIndex = 1
        tabBarController?.tabBar.hidden = false
        self.navigationController?.popToRootViewControllerAnimated(false)
    }

关于ios - 从 UIViewController 过渡到 TabBarViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36528912/

相关文章:

iOS 20mb 构建限制

ios - Swift:使用本地化的百万和十亿文本格式化货币

ios - 如何在登录用户通过 Facebook 在 firebase for ios swift 登录后进行检查?

iphone - 从 shoutcast iOS 编程获取元数据

ios - 使用 3 个 slider 动态设置 ios 应用程序的背景图像

json - 快速搜索 JSON

ios - 关闭应用程序并在 appstart 上启动 webview

iphone - 来自Jay Freeman Saurik的Cycript,将其链接到其他程序时出现一个奇怪的错误

ios - swift如何处理 header 响应navigationAction.request.allHTTPHeaderFields中的多个cookie? ["Set-Cookie"]

xml - Swift:创建 NSXMLNode