1

我已使用以下代码成功将 NSTextField 添加到 NSAlert:

NSAlert *alert = [NSAlert alertWithMessageText: @"Password"
                                          defaultButton:@"OK"
                                        alternateButton:@"Cancel"
                                            otherButton:nil
                              informativeTextWithFormat:@""];

         NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
         [input setStringValue:@""];
         [input autorelease];
         [alert setAccessoryView:input];

         NSInteger button = [alert runModal];

但是,NSAlert 上显示的 NSTextField 不允许键入文本,无论我输入什么,它都不会显示在 NSTextField 上。我还尝试了将 Enabled 和 Editable 设置为 YES 但没有任何改变。

4

0 回答 0