xcode 将连接从故事板拖到应用程序委托

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10573713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:18:21  来源:igfitidea点击:

Dragging connections from a storyboard to the app delegate

iosxcodeinterface-builderuistoryboard

提问by Basil Al-Dajane

I can't seem to find this anywhere, but I'm having issues trying to create reference outlets in my storyboard to my app delegate for UIWindowand UIViewController. The UIViewControllers are from a UISplitViewController. From examples I've seen that use a xib file rather than a storyboard, the IBOutlets seem to be made by "clicking and dragging".

我似乎在任何地方都找不到这个,但是我在尝试在我的故事板中为我的应用程序委托创建参考插座时遇到了问题UIWindowUIViewController。该UIViewControllers是一个UISplitViewController。从我看到的使用 xib 文件而不是故事板的示例中,IBOutlets 似乎是通过“单击和拖动”制作的。

I'm completely lost on the issue as Xcode won't let me drag any outlet into my app delegate. If you could help point out what I'm doing wrong, I'd greatly appreciate it.

我完全迷失在这个问题上,因为 Xcode 不允许我将任何插座拖到我的应用程序委托中。如果您能帮助指出我做错了什么,我将不胜感激。

采纳答案by heckman

XCode and Story boards will typically only let you drag and connect outlets to view controllers. When using storyboards, select an item as the root view controller, and then do you communication and segues from there. If you are simply trying to map things to your storyboard, you should be able to find you to do something similar to:

XCode 和故事板通常只允许您拖动和连接插座到视图控制器。使用故事板时,选择一个项目作为根视图控制器,然后从那里进行通信和转场。如果您只是尝试将事物映射到故事板,您应该能够找到您执行以下操作:

UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;

If you have a general 'data sharing' class a singleton is a great way to always get a common instance of a class and ensure that all referencing classes are using the same information.

如果你有一个通用的“数据共享”类,单例是一个很好的方法,可以始终获得一个类的公共实例,并确保所有引用类都使用相同的信息。