Alex Alex - 1 year ago 66
Swift Question

View controls do not show up using Interface Builder

Even I'm a Swift beginner, it should be simple but I don't know why. I'm not keen to use Storyboard so I decided to go for the Interface Builder. After adding several elements into my view controller, they are not showing up when I run my app. The following is my code:

window = UIWindow.init(frame: UIScreen.main.bounds)
let home = HomeViewController()
window!.rootViewController = home

I've already set
to the
File's Owner

Answer Source

The problem would be this line:

let home = HomeViewController()

You should change it to

let home = HomeViewController(nibName: "Whatever the name of your xib file is", bundle: nil)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download