简体   繁体   中英

loading ViewController(containing xib) using xib

I am trying to create Viewcontroller with xib. Here this viewcontroller contains a tableview. If I load viewController with connecting tableview with @IBOlet reference then view controller works fine. But when I connect tableview reference with my xib viewcontroller then at runtime, I get this error.

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fc02602d8e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key searchResultTableView1.'

I am completely sure that my tableview is connected with the right reference. I don't know which step, I am missing

here are pictures of how I am loading viewcontroller from xib

searchViewController.xib searchViewController.xib pic here

searchViewController.swift searchViewController pic here

loading from the main view controller loading from main view controller picture here

after 4 to 5 hours now I got to the point that I was instantiating xib viewcontroller using

let vc1 = UIViewController(nibName: "SearchViewController", bundle: nil)

so now I tried to instantiate a view controller with viewcontroller constructor

let vc1 = SearchViewController(nibName: "SearchViewController", bundle: nil)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM