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

2019-04-14 15:29发布

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?

标签: xcode swift ios9
2条回答
家丑人穷心不美
2楼-- · 2019-04-14 15:49

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

enter image description here

查看更多
看我几分像从前
3楼-- · 2019-04-14 15:59

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.

查看更多
登录 后发表回答