我希望有人可以帮助我解决这个问题。
无论我做什么,无论是通过 IB 还是在代码中,我都无法使新的 NSSplitViewController 及其项目可折叠或保持其优先级。
尽管此视频另有显示,但无法从界面构建器中完成:https ://www.youtube.com/watch?v=ZIIuPo4F6tQ
我只能使 splitview 项目在代码中具有最小宽度,但这就是它。我测试了 Swift 和 Objective-C 的实现都没有运气。
这是我用swift写的:
override func viewDidLoad() {
super.viewDidLoad()
// ---
var left: NSSplitViewItem = self.splitViewItems[0] as NSSplitViewItem
var right: NSSplitViewItem = self.splitViewItems[1] as NSSplitViewItem
// ---
// NOTE: these are not working properly in the interface builder for now
self.view.addConstraint(NSLayoutConstraint(
item: left.viewController.view,
attribute: NSLayoutAttribute.Width,
relatedBy: NSLayoutRelation.GreaterThanOrEqual,
toItem: nil,
attribute: NSLayoutAttribute.NotAnAttribute,
multiplier: 0,
constant: 200
))
self.view.addConstraint(NSLayoutConstraint(
item: right.viewController.view,
attribute: NSLayoutAttribute.Width,
relatedBy: NSLayoutRelation.GreaterThanOrEqual,
toItem: nil,
attribute: NSLayoutAttribute.NotAnAttribute,
multiplier: 0,
constant: 200
))
// ---
// NOTE: these are not working in the interface builder neither here but set anyway to demonstrate the problem
left.canCollapse = true // has no effect
right.canCollapse = true // has no effect
// ---
// NOTE: this is not working in the interface builder neither here but set anyway to demonstrate the problem
right.holdingPriority = 1.0 // has no effect
}
这些都不起作用。我什至尝试将调用移动到函数底部的 super ,但运气不佳。
我想知道是否有人已经确定了解决方案,或者我做错了什么?