我的 OS X 应用程序的 ViewController 中有以下代码:
NSAlert *alert = [NSAlert new];
alert.messageText = @"Connection error";
alert.informativeText = @"You do not appear to be connected to the internet";
[alert addButtonWithTitle:@"Third button"];
[alert addButtonWithTitle:@"Second button"];
[alert addButtonWithTitle:@"Ok"];
[alert beginSheetModalForWindow:[[self view] window] completionHandler:^(NSInteger result) {
NSLog(@"Success");
}];
// [alert runModal];
当这段代码执行时,什么也没有发生。如果我注释掉 beginSheetModalForWindow 行,并取消注释 [alert runModal],则警报将按预期显示。
我在这里做错了什么,它没有显示为工作表?