showViewController method only displays modal views

756 Views Asked by At

Looking at Apples Resource for using showViewController() versus presentViewController() I can't seem to figure out my issue here.

I want to display a viewController from my storyboard programmatically by doing the following:

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

This works fine. However, it's presentation is always modal. Covering the screen vertically from bottom to top like so:

modal display

I was/still am under the impression that I should use showViewController to display a screen without the animation... But clearly I'm missing something here. All I want to do is display the VC non-modally. I feel like I've tried everything to no avail.

Thanks for the advice in advance.

1

There are 1 best solutions below

1
On BEST ANSWER

I think you want to use something like this.

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

The key is to have animated set to false. This method works for me. Hope this helps!