【问题标题】:Use toolbar to navigate properly使用工具栏正确导航
【发布时间】:2015-09-08 09:47:25
【问题描述】:

我正在尝试做一个类似 instagram(或任何带有工具栏的应用程序)的工具栏,以便从一个屏幕导航到另一个屏幕。

我有一个导航控制器,有 5 个屏幕,我已经这样做了:

  • 在每个屏幕中,在 viewDidLoad 中,我输入:

self.toolbarItems = self.navigationController!.toolbarItems

  • 在导航控制器中,对于一个 BartbuttonItem 我有这个 函数举例:

@IBAction func profileButtonClicked(sender: UIBarButtonItem) { self.popToRootViewControllerAnimated(false) self.performSegueWithIdentifier("showProfile", sender: self) }

所以它可以工作,但是我不喜欢先到 navigationController 然后再到 newViewController 的转换,我希望根本没有转换。

如果你能帮助我,我将不胜感激。

【问题讨论】:

    标签: ios swift navigation toolbar swift2


    【解决方案1】:
    1. 单击主情节提要上的视图控制器
    2. 然后转到属性检查器
    3. 有一个选项叫做过渡风格,选择交叉溶解

      或使用

        self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController, animated: false, completion: nil)
      

    【讨论】:

    • 嗨,我试过了,但这不起作用,我仍然看到第一个viewController(rootedViewController):/
    • 选择所有的viwcontrollers并按照上面的操作然后运行,仍然得到这样的输出?
    • 是的,这就是我刚刚做的,我仍然没有任何区别
    • 这是一种工作,但不是真的,因为当我使用 push segue 中的 backButton 时,我到达了第二个 viewController,而不是 RootViewController
    • 例如,使用您的解决方案,如果我在按钮上单击 5 次,那么我将在 backButton 上单击 5 次以到达我的第一个..
    【解决方案2】:

    找到:

    只需要取消选中“动画”,当您单击故事板中的 segue 然后转到属性检查器并取消选中此复选框。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-09
      • 1970-01-01
      • 1970-01-01
      • 2019-12-25
      • 2019-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多