0
我試圖運行下面的代碼,我在此網站上發現,Sample code for creating a NSTextField "label"?:添加標籤到主視圖
#import "AppController.h"
@implementation AppController
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSTextField *textField;
textField = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 10, 200, 17)];
[textField setStringValue:@"My Label"];
[textField setBezeled:NO];
[textField setDrawsBackground:NO];
[textField setEditable:NO];
[textField setSelectable:NO];
[view addSubview:textField];
}
@end
不過,我得到了錯誤:「視圖」是不確定的。我究竟做錯了什麼?我必須鏈接一些東西嗎?
我以爲視圖指的是主筆尖文件/窗口。如何將標籤添加到主窗口? – Ali 2011-06-14 13:58:14