Reputation: 4025
Using iOS 8 and Xcode 6. I embedded a UIWebView in a controller using a storyboard, and hooked everything up. When I run it, though, the webView is coming up nil. Any thoughts?
Upvotes: 5
Views: 870
Reputation: 1240
I encountered this problem myself and finally found a solution: At some point Apple changed the way View Controllers are linked with their xib files. Xcode no longer automatically matches, for example, ViewController.swift and ViewController.xib. Instead you must explicitly specify a nib name in your code. Try calling:
NSBundle.mainBundle().loadNibNamed("ViewController", owner: self, options: nil)
or, in Objective C:
[[NSBundle mainBundle] loadNibNamed:@"ViewController" owner:self options:nil];
in your VC's initializer, before you use any IBOutlets (replacing "ViewController" with the name of your View Controller). This is what finally worked for me (in Swift).
See also:
Are view controllers with nib files broken in ios 8 beta 5?
Swift proper way to load xib file
Upvotes: 0
Reputation: 426
What helped me is this answer #1 here.
Exactly in this order.
Upvotes: 1