问题
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