V.Boersch-Supan V.Boersch-Supan - 2 months ago 4x
Swift Question

View Controller not showing properly

I have 4 view controllers of which 3 are perfectly working.
All of them have an own .swift file and are linked using a storyboard.
The last view controller doesn't show up properly though there is nothing that could possibly prevent it from doing so.

Here is an extract of the file that calls the last view controller:

func showBook()
self.presentViewController(BookViewController(), animated: true, completion: nil)

Here is the file that is called:

import UIKit

class BookViewController: UIViewController {

override func viewDidLoad() {


The code doesn't throw any error, prints "BookViewController" and if I set the background color of the view programmatically, it works just fine. But it doesn't show the content set in the storyboard.

Here is a screenshot of my storyboard (only the relevant part):

Note: All the other view controllers are not shown programmatically but using a "present modally" - segue. When I try and use a "present modally" - segue with the last view controller, it also works fine


You need to set the Storyboard ID of your viewcontroller, and use self.storyboard?.instantiateViewControllerWithIdentifier("theIdentifier") instead of creating the BookViewController with a constructor.