我在 XCode 中创建了一个新的 macOS 应用程序。
我添加了
com.apple.security.files.user-selected.read-write
带有值的权利YES
(以允许使用NSSavePanel
)在
AppDelegate.m
中,我实现applicationDidFinishLaunching
如下:- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSSavePanel* nssavepanel = [NSSavePanel savePanel]; NSButton* nsbutton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 20)]; [nsbutton setTitle:@"Button title"]; [nssavepanel setAccessoryView:[[NSView alloc] initWithFrame:NSMakeRect(0, 0, 200, 80)]]; [[nssavepanel accessoryView] addSubview:nsbutton]; [nssavepanel beginWithCompletionHandler:^(NSModalResponse result) {}]; }
当我启动应用程序时,我看到一个带有按钮的面板。
在macOS 10.15.3 上,我可以单击附件视图中的按钮。
在macOS 11.0 Beta (20A4300b)上,我无法单击按钮——整个附件视图似乎已被禁用。(如果我使用runModal
orbeginSheetModalForWindow
代替beginWithCompletionHandler
,附件视图按预期工作。)这是一个错误吗?我在这里做错了吗?