Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的应用程序中有一堆以编程方式创建的 NSButton。如何在不使用 Interface Builder 的情况下设置这些 NSButtons 的子类?
创建按钮时,不要将它们创建为 NSButton,将它们创建为您的子类。例如,如果你有一个NSButton被调用的子类MyButton,而不是类似:
NSButton
MyButton
NSButton *button = [[NSButton alloc] initWithFrame:frame];
你会有类似的东西:
MyButton *button = [[MyButton alloc] initWithFrame:frame];
这种方式button将是MyButton.
button