简体   繁体   中英

how to create referencing outlet to ScrollView without getting key value coding-compliant error

So from a working state, if I ad a referencing outlet from my scroll view to the controller it is in, I crash at run-time from

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

class TaskDetailController : UIViewController {
     @IBOutlet weak var taskDetailScrollView: UIScrollView!

override func viewDidLoad(){
    let contentRect: CGRect = taskDetailScrollView.subviews.reduce(into: .zero) { rect, view in
        rect = rect.union(view.frame)
    }
    taskDetailScrollView.contentSize = contentRect.size
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if (segue.identifier == "TaskDetailTableEmbedSegue") {
        segue.destination.view.translatesAutoresizingMaskIntoConstraints = false;
    }
}

I don't see why this referencing outlet is different from the dozens of others I've done.

I'm wondering if I violated some layout constraint rule, but I don't see why that would relate to this.

Very bizarre, but if I delete the referencing outlet then it runs fine. But I need a referencing outlet. Also interface builder recognizes the outlet connection and fills in the circle, so why does it have an issue?

   TitleBarView
   MainSectionView
       ScrollView
       ButtonView
   BottomBarView

The issue was that somehow the controller's inherit module from target had become undone.

I am kind of surprised that any wiring can be done if it cannot even find the controller class. The error itself is a bit cryptic as it makes it sound as if it is an IBOutlet error rather than the controller itself not being found.

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