gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 10:22:12 26 4
gpt4 key购买 nike

我想在我的应用程序中创建一个按钮,以便使用 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/

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