Can't CTRL+Drag NSButton to custom NSView header

[亡魂溺海] 提交于 2019-12-02 06:21:05

问题


I'd like to create a custom NSTableCellView instantiated by Interface Builder. I've set my Table Cell View class to MyTableCellView, and properly created MyTableCellView : NSTableCellView .m/.h files.

However, I just can't CTRL+Drag a simple button from inside this view to MyTableCellView.h in order to create an IBOutlet.

Here is a video to show what happens: http://youtu.be/sNNbuVT-SZs.

How the view is subclassed:

How I try to CTRL+Drag a button

Also, sometimes, Interface Builder just don't allow the cell view's class to be modified. What's happening ?


回答1:


I finally found a solution, that is a little weird but works as expected. Instead of connecting the NSButton to MyTableCellView header directly, I used the reversed path:

Manually create an outlet:

@property(retain, nonatomic) IBOutlet NSButton* button;

Then click the empty circle on the left, and drag it to your XIB file's button:

I have no idea why it works this way, please let me know if you know the anwser.



来源:https://stackoverflow.com/questions/11811765/cant-ctrldrag-nsbutton-to-custom-nsview-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!