Xib file: Can't drag a View from a xib file to

2019-04-14 15:33发布

问题:

I just dragged and dropped a View to a xib file. I added some constrains and tried to Ctrl drag from the View to a .swift file with the assistant editor, but it bounce back, what am I missing?

回答1:

The xib file needs to be a subclass of the file you are trying to ctrl+drag to.



回答2:

I was setting the View's custom class instead of the File's Owner. Once I set the File's Owner to the custom class, I was able to control-drag from the view in the storyboard over to my class. Hope this helps someone.



标签: xcode swift ios9