MAC开发-NSAlert的简单用法

2017-08-22  本文已影响148人  雅雅克

开发当中NSAlert,在删除消息,退出登录等场景中会用到。代码如下:

    NSString *message = @"这里是提示的信息";
    NSAlert *alert = [NSAlert new];
    [alert addButtonWithTitle:@"确定"];
    [alert addButtonWithTitle:@"取消"];
    [alert setMessageText:message];
    [alert setAlertStyle:NSCriticalAlertStyle];
    [alert beginSheetModalForWindow:[self.view window] completionHandler:^(NSModalResponse returnCode) {
        if(returnCode == NSAlertFirstButtonReturn){
           //确定
        }else if(returnCode == NSAlertSecondButtonReturn){
           //取消 
        }
    }];
上一篇 下一篇

猜你喜欢

热点阅读