OSX 10.10 中的 NSSplitViewController 使用 Xcode 6 [英] NSSplitViewController in OSX 10.10 using Xcode 6

查看:77
本文介绍了OSX 10.10 中的 NSSplitViewController 使用 Xcode 6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 NSSplitViewControllers 的文档,关联的 NSSplitView 使用 NSSplitViewController 作为其委托.具体在文档中,拆分视图控制器充当其拆分视图对象(管理分隔符的对象)的委托.如果您覆盖拆分视图委托方法,则您的覆盖必须调用 super."

According to documentation on NSSplitViewControllers, the associated NSSplitView uses the NSSplitViewController as its delegate. Specifically in the documentation, "The split view controller serves as the delegate of its split view object (the object that manages the dividers). If you override a split view delegate method, your override must call super."

我在界面构建器中实现了一个 NSSplitViewController 并给它一个类.但是,从来没有调用过 splitView 委托.此外,如果我只是做一些类似吐谁 splitView 委托 [ NSLog (@"%@", self.splitView.delegate); 的事情.],结果为空".但是,如果我在 IB 本身(通过将委托出口拖到 NSSplitViewController)或内部代码([self.splitView setDelegate:self];)中分配委托,我会收到以下错误:

I have implemented an NSSplitViewController in interface builder and gave it a class. However, none of the splitView delegates are ever invoked. Additionally, if I just do something like spit who the splitView delegate [ NSLog (@"%@", self.splitView.delegate); ], the result is "null". If, however, I assign the delegate either in IB itself (by dragging the delegate outlet to the NSSplitViewController) or inside code ([self.splitView setDelegate:self];), I get the following error:

引发了未捕获的异常
SplitViewController 的 splitView 无法使用自动布局,因为 SplitViewController 覆盖了不兼容的委托方法.

An uncaught exception was raised
SplitViewController's splitView is unable to use autolayout because the SplitViewController overrides an incompatible delegate method.

我完全糊涂了.

推荐答案

如果拆分视图的委托实现了以下方法之一,它将与自动布局不兼容.

If the delegate of a split view implements one of the following methods, it becomes incompatible with auto layout.

splitView:constrainMinCoordinate:ofSubviewAt:
splitView:constrainMaxCoordinate:ofSubviewAt:
splitView:resizeSubviewsWithOldSize:
splitView:shouldAdjustSizeOfSubview:

https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKitOlderNotes/#10_8AutoLayout

并且因为 NSSplitViewController 需要使用自动布局(在文档中提到),这些方法与 NSSplitViewController 不兼容,不应在子类中实现.

And because NSSplitViewController requires the use of auto layout (mentioned in the documentation), these methods are incompatible with NSSplitViewController and shouldn't be implemented in a subclass.

这篇关于OSX 10.10 中的 NSSplitViewController 使用 Xcode 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆