xcode 无法 ctrl+drag 从第二个 ViewController 进入 ViewController.h

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14491275/
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 02:36:23  来源:igfitidea点击:

Can't ctrl+drag into ViewController.h from second Viewcontroller

xcodeinterface-builder

提问by Tom

I am building an iOS app for fun and here is where I run into trouble. I can insert an outlet and action in the ViewController.h files directly from my first View Controller through the ctrl+drag method; however, when I try ctrl+drag on the second ViewController it will not allow me.

我正在构建一个有趣的 iOS 应用程序,这就是我遇到麻烦的地方。我可以直接从我的第一个视图控制器通过 ctrl+drag 方法在 ViewController.h 文件中插入一个插座和动作;但是,当我在第二个 ViewController 上尝试 ctrl+drag 时,它不允许我。

Ctrl+drag on first ViewController

Ctrl+拖动第一个 ViewController

Ctrl+drag on second ViewController

Ctrl+拖动第二个 ViewController

回答by foundry

You have the wrong document open in the assistant editor. It should be ViewController.h, but you are displaying UIViewController.h.

您在助理编辑器中打开了错误的文档。它应该是 ViewController.h,但您显示的是 UIViewController.h。

Check you have correctly set your second view controller to your custom class ViewController using the Identity Inspector (third of the right hand utility panels) then make sure it's header file is the document you are displaying on the right.

检查您是否已使用 Identity Inspector(右侧实用程序面板的第三个)将第二个视图控制器正确设置为自定义类 ViewController,然后确保它的头文件是您在右侧显示的文档。

update

更新

From your comments, you are having difficulty setting the second view controller to a custom class.

根据您的评论,您很难将第二个视图控制器设置为自定义类。

Here is how you select it in the storyboard. Note that you are selecting the View Controller, not it's topmost View

这是您在故事板中选择它的方法。请注意,您选择的是View Controller,而不是最顶层的View

enter image description here

在此处输入图片说明

回答by Leonardo Simoes

Copy and paste the class in the field "Class." You then need to press ENTER to take effect. Example

将类复制并粘贴到“类”字段中。然后您需要按 ENTER 才能生效。例子