How do I load a second view correctly in Swift?
Posted
by
slooker
on Stack Overflow
See other posts from Stack Overflow
or by slooker
Published on 2014-06-03T21:21:07Z
Indexed on
2014/06/03
21:24 UTC
Read the original article
Hit count: 181
I have a view that I'm trying to load in Swift like this, but it crashes with this error: 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "DetailView" nib but the view outlet was not set.'
Here is the code I'm trying to use to load it.
Second View Controller
import UIKit
class DetailViewController: UIViewController {
@IBOutlet var nameField: UITextField
override func viewDidLoad() {
super.viewDidLoad()
}
}
Code to load the view controller:
var newViewController = DetailViewController()
@IBAction func buttonTapped(AnyObject) {
println("button tapped!")
self.presentViewController(newViewController, animated: true, nil)
}
What am I doing wrong?
© Stack Overflow or respective owner