【问题标题】:Drag a folder to dock icon in non-document-based app将文件夹拖动到非基于文档的应用程序中的停靠图标
【发布时间】:2019-05-24 01:47:36
【问题描述】:

到目前为止,我已经尝试了每种文档类型和委托方法,但我的非基于文档的应用程序不接受停靠图标上的任何拖放文件/文件夹。

这是我从 Apples Notes 应用程序复制的文档类型,它支持在其图标上放置文件夹:

<dict>
    <key>CFBundleTypeName</key>
    <string>General files and folders</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSItemContentTypes</key>
    <array>
        <string>public.folder</string>
    </array>
</dict>

委托设置正确,否则我的applicationWillFinishLaunching根本不会被调用。

我尝试实现任何一个

  • application(_ sender: NSApplication, openFile filename: String) -&gt; Bool
  • application(_ sender: NSApplication, openFiles filenames: [String])

没有成功。我只是无法让停靠图标接受下降。我错过了什么?

更新:

事实证明,我必须将 Debug 构建拖到 /Applications 才能接受拖动。至少可以说,这非常麻烦。有什么办法吗?

【问题讨论】:

    标签: swift macos cocoa


    【解决方案1】:

    这看起来很奇怪,但这是我为使其正常工作所做的:

    • Debug 构建拖到/Applications
    • 启动它并将文件拖到其中
    • 再次从 Xcode 构建并运行应用程序。 /Applications 之外的 Xcode 构建现在也接受 Drop
    • 您现在可以从 /Applications 中删除复制的版本,删除仍然有效。

    【讨论】:

      猜你喜欢
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-20
      • 1970-01-01
      • 2011-03-10
      相关资源
      最近更新 更多