我想放的NSTextField,這本身就是一個NSAlert 這裏面內部的屬性串是我的代碼:[__NSCFConstantString的pointsize]:無法識別的選擇發送到instanc
NSTextField *label1 = [[NSTextField alloc]initWithFrame:NSMakeRect(0, 23, 50, 20)];
[label1 setEditable:FALSE];
[label1 setAllowsEditingTextAttributes:TRUE];
[label1 setBezeled:FALSE];
label1.backgroundColor = [NSColor clearColor];
NSString *login = @"Username";
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:login];
NSString *boldFontName = [[NSFont boldSystemFontOfSize:12] fontName];
[attrString beginEditing];
NSRange ran = NSMakeRange(0, 8);
[attrString addAttribute:NSFontAttributeName
value:boldFontName
range:ran];
[attrString endEditing];
NSLog(@"%@",attrString);
[label1 setAttributedStringValue:attrString];
[alert setAccessoryView:label1];
[alert runModal];
然而,一旦[ alert runModal]被調用,我的應用程序崩潰
"[__NSCFConstantString pointSize]: unrecognized selector sent to instance 0x7fff74035bb0"
我不知道爲什麼會發生這種情況。它似乎與字符串有關,因爲只要我刪除[alert setAccessoryView:label1]或給label1一個標準的nsstring,它就可以正常工作。請幫忙!
嗨下來選民!你爲什麼這樣做? –