cocoa - Swift - 选择文件时发出警告(Cocoa)

标签 cocoa swift warnings finder

我想在我的应用程序中创建一个按钮,以便使用 Swift 通过 Finder 选择文件。

@IBAction func selectFiles(sender : NSButton) {
    let openDlg = NSOpenPanel()
    openDlg.allowsMultipleSelection = true
    openDlg.canChooseFiles = true
    openDlg.canChooseDirectories = true
    if openDlg.runModal() == NSOKButton{
        files = openDlg.URLs
    }
}

当我运行此代码时,出现以下警告。

Unable to simultaneously satisfy constraints:
(
    "<NSAutoresizingMaskLayoutConstraint:0x608000095450 h=-&- v=-&- H:|-(0)-[NSView:0x608000125b40]   (Names: '|':FIFinderView:0x600000143de0 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x6080000954a0 h=-&- v=-&- H:[NSView:0x608000125b40]-(0)-|   (Names: '|':FIFinderView:0x600000143de0 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x608000095680 h=--& v=--& H:[FIFinderView:0x600000143de0(712)]>",
    "<NSLayoutConstraint:0x60800008cbc0 H:[NSView:0x608000125a00]-(0)-|   (Names: '|':NSView:0x608000125b40 )>",
    "<NSLayoutConstraint:0x60800008cc10 H:|-(0)-[NSView:0x608000125a00]   (Names: '|':NSView:0x608000125b40 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x608000092ed0 h=-&- v=-&- H:|-(0)-[NSClipView:0x100541110]   (Names: '|':FI_TSidebarScrollView:0x6000001c1b30 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x608000092f20 h=-&- v=-&- H:[NSClipView:0x100541110]-(15)-|   (Names: '|':FI_TSidebarScrollView:0x6000001c1b30 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x6080000935b0 h=-&- v=-&- H:|-(0)-[FI_TSidebarScrollView:0x6000001c1b30]   (Names: '|':NSView:0x600000123660 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x608000093600 h=-&- v=-&- H:[FI_TSidebarScrollView:0x6000001c1b30]-(0)-|   (Names: '|':NSView:0x600000123660 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x608000093790 h=-&- v=-&- H:|-(0)-[NSView:0x600000123660]   (Names: '|':FI_TSidebarSplitView:0x600000143f40 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x6080000937e0 h=-&- v=-&- H:[NSView:0x600000123660]-(709)-|   (Names: '|':FI_TSidebarSplitView:0x600000143f40 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x608000095270 h=-&- v=-&- H:|-(0)-[FI_TSidebarSplitView:0x600000143f40]   (Names: '|':NSView:0x608000125a00 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x6080000952c0 h=-&- v=-&- H:[FI_TSidebarSplitView:0x600000143f40]-(0)-|   (Names: '|':NSView:0x608000125a00 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60800008cbc0 H:[NSView:0x608000125a00]-(0)-|   (Names: '|':NSView:0x608000125b40 )>

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens.  And/or, break on objc_exception_throw to catch this in the debugger.

即使我不消除此警告,我的应用程序也运行良好,但我想知道如何删除它。

最佳答案

这是 NSOpenPanel 的问题。有关此问题的错误报告已提交给 Apple,但在他们修复之前,恐怕您无能为力。 幸好你的代码运行良好:)

关于cocoa - Swift - 选择文件时发出警告(Cocoa),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25462675/

相关文章:

Xcode 警告 : "Multiple build commands for output file"

objective-c - 为什么使用 NSAppleScript 打开 2 个终端窗口?

ios - Swift 在 UITableView 中为容器 View 设置约束

ios - 从子 UIVIewController 控制 UIScrollView

具有 XIB 和固定尺寸的 IOS 自定义 UIView

c - MPLABX XC16 无法解析内置标识符 __builtin_dmaoffset

objective-c - 在基于文档的应用程序中连接菜单项

cocoa - 在 mac os X Dock 中添加自定义 View /窗口

cocoa - Cocoa 中未本地化的字体集合名称

ios - 在应用程序运行时检查内存使用情况