从10.10开始:使用modalFor ...来获取自定义工作表对于beginSheet:completionHandler: 因此,使用storyboard我只使用NSViewController来“NSWindow”,就像customSheetView.view.window一样。 这是我的代码,但是当我按下我的btn时,没有任何事情发生。
#import "vv.h"
@property (strong) vv *customSheetView;
@synthesize customSheetView;
- (IBAction)displayCustomSheet:(id)sender {
if (!customSheetView) {
customSheetView = [[NSStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateControllerWithIdentifier:@"sheet"];
}
//[[NSApplication sharedApplication].windows objectAtIndex:0]
[customSheetView.view.window beginSheet:self.view.window completionHandler:^(NSInteger result) {
switch (result) {
case 0:
self.outputLabel.stringValue = @"ok";
break;
case 1:
self.outputLabel.stringValue = @"cancel";
break;
default:
self.outputLabel.stringValue = @"You did something";
break;
}
}];
}