为此,我的代码是
- (int)ldapAlertMessage:(NSString *)alertMessage
{
int x=0;
if (nil != alertMessage) {
NSImage *alertIcon = [NSImage imageNamed:@"security_alert_icon"];
NSAlert *alert = [[NSAlert alloc]init];
[alert addButtonWithTitle:@"Yes"];
[alert addButtonWithTitle:@"No"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:alertMessage];
[alert setAlertStyle:NSWarningAlertStyle];
[alert setIcon:alertIcon];
[[alert window] setBackgroundColor: NSColor.whiteColor];
int result= [alert runModal];
switch(result)
{
case NSAlertFirstButtonReturn:
{
x=1;
return x;
break;
}
case NSAlertSecondButtonReturn:
{
x=2;
return x;
break;
}
case NSAlertThirdButtonReturn:
{
x=3;
return x;
break;
}
}
}
return x;
}
使用
调用 user_response = [self ldapAlertMessage: @"You will no longer be able to access your ldap login on this device if you select this."];
根据按钮执行时定义的用户响应操作。
我想要一种方法来了解如何让我的按钮垂直显示,因为我会更改文本是,不会更大。