我希望有人能帮我解决这个问题。
无论我做什么,无论是通过IB还是在代码中,我都不能使新的NSSplitViewController及其项目折叠或保留它们的优先级。
它不能从接口构建器中完成,尽管这个视频显示的不是:https://www.youtube.com/watch?v=ZIIuPo4F6tQ。
我只能使splitview项在代码中具有最小的宽度,但这差不多就是了。我测试了Swift和Objective实现,但没有成功。
这就是我用斯威夫特写的:
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
}这些都不起作用。我甚至试着把调用转移到函数底部的超级程序,结果却没有什么好运气。
我想知道是有人找到了解决方案,还是我做错了什么?
发布于 2014-11-19 22:09:58
(一个问题:崩溃后,我无法用鼠标返回折叠视图;这可能需要实现有效的rect委托方法。更新:有效的rect在崩溃时不适用,所以我认为在代码中使用NSSplitViewItem.collapsed似乎是避免崩溃的唯一方法。这种行为不同于“经典”NSSplitView.)
此基本设置按预期工作,不需要特定的编码或覆盖。(OS X Storyboard应用程序,Swift,Xcode 6.1)
https://stackoverflow.com/questions/26671160
复制相似问题