美文网首页
MAC开发-NSAlert的简单用法

MAC开发-NSAlert的简单用法

作者: 雅雅克 | 来源:发表于2017-08-22 12:15 被阅读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){
           //取消 
        }
    }];

相关文章

网友评论

      本文标题:MAC开发-NSAlert的简单用法

      本文链接:https://www.haomeiwen.com/subject/mktldxtx.html