1

查看 Apples Resource for usingshowViewController()presentViewController()我似乎无法在这里找出我的问题。

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

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

这工作正常。然而,它的呈现总是模态的。从下到上垂直覆盖屏幕,如下所示:

模态显示

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

提前感谢您的建议。

4

1 回答 1

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。这种方法对我有用。希望这可以帮助!

于 2016-05-07T19:25:03.120 回答