设为首页 加入收藏

TOP

Xcode Cocoa程序MessageBox 弹框
2015-11-21 00:58:51 来源: 作者: 【 】 浏览:2
Tags:Xcode Cocoa 程序 MessageBox 弹框

相信很多Windows程序员都习惯MessageBox弹框提示, 在MacOS下也有类似MessageBox这种弹框提示方法

第一种方法

?

    //其他的各种弹框类型
    NSAlert *alert = [[NSAlert alloc] init];
    //[alert addButtonWithTitle:@"OK"];
    //[alert addButtonWithTitle:@"Cancel"];
    [alert setMessageText:@"test?"];
    //[alert setInformativeText:@"Deleted records cannot be restored."];
    //[alert setAlertStyle:NSWarningAlertStyle];
    // [alert setHelpAnchor:@"ddd"];
    // [alert setInformativeText:@"asdfa"];
    // [alert setMessageText:strMsg];
    /*
     [alert beginSheetModalForWindow:_window
     modalDelegate:self
     didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
     contextInfo:nil];  
     */  
    [alert runModal];

第二种方法

?

?

    CFOptionFlags  result;
    NSString *strMsg = [NSString stringWithFormat:@"%i", 234];
    CFStringRef* msg_ref;
    
    CFUserNotificationDisplayAlert(0,
                                   kCFUserNotificationNoDefaultButtonFlag,
                                   NULL, NULL, NULL,
                                   CFSTR("Title"),
                                   CFSTR("Message"),
                                   NULL, NULL, NULL, &result);


?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 1655 Balancing Act (树的重.. 下一篇leetcode 228: Summary Ranges

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: