Why does this code not work?
-
29-09-2019 - |
문제
So I have the following code to create an NSButton, and put it on the screen. However, when I run this code, nothing happens. What is wrong with this?
NSButton *newbutton = [[NSButton alloc] initWithFrame:NSMakeRect(100, 100, 109, 151)];
[newbutton setImage:[NSImage imageNamed:@"4Diamonds.png"]];
해결책
The button doesn't appear magically by itself. You have to add it to a visible view, e.g. by using -[NSView addSubView:]
.
제휴하지 않습니다 StackOverflow