3
  • 我在 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)上,我无法单击按钮——整个附件视图似乎已被禁用。(如果我使用runModalorbeginSheetModalForWindow代替beginWithCompletionHandler,附件视图按预期工作。)这是一个错误吗?我在这里做错了吗?

4

0 回答 0