문제

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:].

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top