gpt4 book ai didi

cocoa - 如何在 Mavericks 中打开 NSSheet?

转载 作者:行者123 更新时间:2023-12-03 16:16:00 25 4
gpt4 key购买 nike

在 Mavericks 中,打开和关闭 NSSheets 的方法已更改。为了让它变得更难,Release Notes与当前文档不匹配(见下文)。

我正在尝试这样做:

MainSheetController(NSWindowController):

-(IBAction)callSheet:(id)sender {
[sheetController openSheet];
}

SheetController(NSObject):

 (void)openSheet {  
[[NSBundle mainBundle] loadNibNamed:sheetName owner:self topLevelObjects:nil];
NSLog(@"1");
[self.mainWindowController.window beginSheet:self.sheet completionHandler:nil];
NSLog(@"2");
}

我到达 2,没有错误或警告,但没有工作表..

当前文档:

#if NS_BLOCKS_AVAILABLE
- (void)beginSheet:(NSWindow *)sheetWindow completionHandler:(void (^)(NSModalResponse returnCode))handler NS_AVAILABLE_MAC(10_9);
- (void)beginCriticalSheet:(NSWindow *)sheetWindow completionHandler:(void (^)(NSModalResponse returnCode))handler NS_AVAILABLE_MAC(10_9);
#endif

最佳答案

- (IBAction)userButtonPressed:(id)sender {

UserLoginWindowController * wc = [UserLoginWindowController new];
// we keep a reference, so the WC doesn't deallocate
self.modalWindowController = wc;

[[self window] beginSheet:[wc window] completionHandler:^(NSModalResponse returnCode) {
self.modalWindowController = nil;
}];

}

在 UserLoginWindowController 中

- (IBAction)cancelButtonPressed:(id)sender {

[[[self window] sheetParent] endSheet:[self window] returnCode:NSModalResponseCancel];

}

关于cocoa - 如何在 Mavericks 中打开 NSSheet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19608665/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com