NSWindowController/NSViewController“演示"情节提要中的设置 [英] NSWindowController/NSViewController "Presentation" setting in Storyboard

查看:191
本文介绍了NSWindowController/NSViewController“演示"情节提要中的设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

演示"选项(在属性"检查器中)在StoryBoard for Cocoa中的功能是什么.

What exactly does the Presentation option(in Attribute Inspector) do in StoryBoard for Cocoa.

它提供了两个选项供您选择

It gives two options to select from

  • 单人
  • 多个

P.S在标题上搜索时,结果与PowerPoint演示文稿相关

P.S When googled the title, results are related to powerpoint presentation

推荐答案

演示文稿样式会影响显示"顺序.可能也会影响其他segue,但是我仅测试了Show segue.我在OS X 10.10.5(Yosemite)上使用Xcode 7.1.1进行了测试.

The presentation style affects "Show" segues. Possibly it affects other segues too, but I only tested a Show segue. I tested on OS X 10.10.5 (Yosemite) with Xcode 7.1.1.

如果窗口控制器的演示样式为多个"(默认),则向窗口控制器显示节目"总是从情节提要中加载窗口控制器的新实例.这意味着您可以一次拥有多个窗口控制器实例,每个实例在屏幕上都有自己的窗口.默认情况下,这些窗口会彼此叠放,因此直到您移动或关闭一个窗口时,发生的情况才会变得明显.

If a window controller's presentation style is "Multiple" (the default), then a Show segue to the window controller always loads a new instance of the window controller from the storyboard. This means that you can end up with multiple instances of the window controller at once, each with its own window on the screen. By default those windows will stack on top of each other, so it won't be obvious what happened until you move or close one.

如果窗口控制器的演示样式为单个",并且已经从情节提要中加载了该窗口控制器的实例,并且该窗口控制器仍然存在(可能是因为其窗口仍在屏幕上),则将显示显示该视图控制器将创建新实例.相反,Show segue会将现有的窗口控制器的窗口置于最前面.

If a window controller's presentation style is "Single", and an instance of the window controller has already been loaded from the storyboard, and that window controller still exists (presumably because its window is still on screen), then a Show segue to that view controller will not create a new instance. Instead, the Show segue will bring the existing window controller's window to the front.

如果您想要像Xcode的设备"窗口这样的行为,在该窗口中只能有一个这样的窗口,则此行为很有用.您在情节提要的窗口"菜单中创建设备"菜单项,然后使用显示"命令将其连接到情节提要中的设备"窗口控制器.将设备"窗口控制器的演示样式设置为单个".现在,该菜单项将永远不会创建另一个设备"窗口控制器(如果已经存在).

This behavior is useful if you want behavior like, say, Xcode's Devices window, where there can only be one such window. You create a "Devices" menu item in the Window menu in your storyboard, and connect it to the Devices window controller in the storyboard with a Show segue. Set the Devices window controller's presentation style to Single. Now the menu item will never create a second Devices window controller if one already exists.

您可能希望以某种方式将窗口的excludedFromWindowsMenu属性设置为true,这样它就不会在窗口"菜单中出现两次(因为默认情况下会将其自身附加到该菜单中).例如,您可以使用NSWindowController的子类对其进行设置:

You'll probably want to somehow set the window's excludedFromWindowsMenu property to true, so it doesn't appear twice in the Window menu (because by default it appends itself to that menu). You could, for example, use a subclass of NSWindowController that sets it:

class DevicesWindowController: NSWindowController {
    override func windowDidLoad() {
        super.windowDidLoad()
        window?.excludedFromWindowsMenu = true
    }
}

视图控制器也具有演示样式,因为您还可以将Show segues连接到视图控制器.连接到视图控制器的Show segue会在运行时自动创建一个包含视图控制器的窗口控制器.窗口控制器的表示样式已有效地设置为视图控制器的样式,因此,如果将视图控制器的表示设置为单一",您将获得相同的单例行为.

View controllers also have a presentation style, because you can also connect Show segues to view controllers. A Show segue connected to a view controller automatically creates a window controller to contain the view controller at runtime. The window controller's presentation style is effectively set to the view controller's, so you get the same singleton behavior if you set the view controller's presentation to Single.

据我所知,情节提要设置没有相应的公共属性或可在代码中使用的方法.

As far as I can tell, the storyboard setting has no corresponding public property or method you can use in code.

如果将Show segue连接到情节提要参考板(Xcode 7中的新增功能),则该segue会忽略目标窗口控制器的表示样式,并且就像是"Multiple"一样.即使目标实际上与参考在同一情节提要中,也会发生这种情况.

If you connect the Show segue to a storyboard reference (new in Xcode 7), then the segue ignores the presentation style of the destination window controller, and acts as if it were "Multiple". This happens even if the destination is actually in the same storyboard as the reference.

这篇关于NSWindowController/NSViewController“演示"情节提要中的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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