开发者

Subclass Programmatically Added NSButton?

I have a bunch of programmatically created NSButtons in my app. How can I go about setting the subclass of these NSButtons without us开发者_C百科ing Interface Builder?


When you create the button, don't create them as NSButtons, create them as your subclass. For example, if you had a subclass of NSButton called MyButton, instead of something like:

NSButton *button = [[NSButton alloc] initWithFrame:frame];

You would have something like:

MyButton *button = [[MyButton alloc] initWithFrame:frame];

This way button will be an instance of MyButton.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜