Pas*_*ass 2 nssplitview autolayout swift xcode6
我希望有人可以帮我解决这个问题.
无论我做什么,无论是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
}
Run Code Online (Sandbox Code Playgroud)
这根本不起作用.我甚至尝试将调用移动到函数底部的super,没有太多运气.
我想知道是否有人确定了解决方案,或者我做错了什么?
iha*_*zed 11
(一个问题:在折叠之后,我无法用鼠标返回折叠视图;这可能需要实现有效的rect委托方法.更新:折叠时有效的rect不适用,所以我认为在代码中使用NSSplitViewItem.collapsed似乎成为解除崩溃的唯一方法.这种行为与'经典'NSSplitView不同......)
此基本设置按预期工作,无需特定编码或覆盖.(OS X Storyboard App,Swift,Xcode 6.1)
| 归档时间: |
|
| 查看次数: |
2892 次 |
| 最近记录: |