标签:
相信很多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);
标签:
原文地址:http://blog.csdn.net/sysprogram/article/details/46624475