【问题标题】:showViewController method only displays modal viewsshowViewController 方法只显示模态视图
【发布时间】:2016-09-02 17:12:32
【问题描述】:

看着 Apples Resource 使用 showViewController()presentViewController() 我似乎无法在这里找出我的问题。

我想通过执行以下操作以编程方式从我的情节提要中显示一个 viewController:

  if let resultController = storyboard!.instantiateViewControllerWithIdentifier("mainTab") as? TabBarController {
       showViewController(resultController, sender: UIBarButtonItem.self)
  }

这很好用。然而,它的呈现总是模态的。像这样从下到上垂直覆盖屏幕:

我曾经/仍然认为我应该使用 showViewController 来显示没有动画的屏幕......但显然我在这里遗漏了一些东西。我要做的就是以非模态方式显示 VC。我觉得我已经尝试了一切都无济于事。

提前感谢您的建议。

【问题讨论】:

    标签: ios swift uiviewcontroller hig


    【解决方案1】:

    我想你想用这样的东西。

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("Controller") as! UIViewController
    self.presentViewController(vc, animated: false, completion: nil) // no animation or presentation as modal because animated is false
    

    关键是将动画设置为false。这种方法对我有用。希望这可以帮助!

    【讨论】:

    • 老兄,你摇滚。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2011-02-10
    • 2011-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多