我正在尝试使用三个标签创建一个应用。我有ViewControllers所有设置和工作,但当我尝试在任何不同的选项卡上运行Web视图,而不是拳头,它崩溃与这样的消息:
2016-10-06 23:17:54.565932 Techaway[6827:2354958] Unknown class ThirdViewController in Interface Builder file.
2016-10-06 23:17:59.520639 Techaway[6827:2354958] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Techaway.SecondViewController 0x100f0bc20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Home.'
如果在第一个ViewController中,它可以很好地工作,这让我很困惑。
SecondViewController中的代码示例:
import UIKit
class SecondViewController: UIViewController {
var url = URL(string: "https://example.com/")!
@IBOutlet weak var webView: UIWebView!
@IBAction func home(_ sender: AnyObject) {
webView.loadRequest(URLRequest(url: url))
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
webView.loadRequest(URLRequest(url: url))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
我只是不明白为什么它在一个地方工作而不是另一个地方!
答案 0 :(得分:0)
您的xib中可能连接不正确。所以你需要在storyboard或xib中删除未引用的IBOutlet表格UIViewController。
有关此内容的更多信息请参阅以下链接 What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"