简体   繁体   English

无法从 ViewController Xcode 将“按钮”连接到 viewcontroller.h

[英]Cannot connect "button" to viewcontroller.h from a ViewController Xcode

图片1

I'm making an email app in which I first started off with embedding the ViewController in Navigation bar, after which I made a "FirstView" in which I added three buttons connecting them to another ViewController for a detailed page.我正在制作一个电子邮件应用程序,我首先将 ViewController 嵌入到导航栏中,然后我制作了一个“FirstView”,在其中我添加了三个按钮,将它们连接到另一个 ViewController 以获得详细页面。 They worked fine, But when I tried to connect another button from the new viewcontroller to viewcontroller.h, It doesn't show any option to.他们工作得很好,但是当我尝试将新视图控制器中的另一个按钮连接到 viewcontroller.h 时,它没有显示任何选项。

图2

Any idea how can I do this?知道我该怎么做吗?

您需要在右上角的“类”中将您的class_name提供给Identity Inspector,然后尝试一下,希望它能起作用...!

Sometimes Xcode behaves a little "buggy". 有时Xcode表现得有些“笨拙”。 Some of the following might help: 以下某些内容可能会有所帮助:

  • You should ensure that your project compiles without error, otherwise Xcode frequently doesn't recognize you D&D 您应确保项目编译无误,否则Xcode经常无法识别您的D&D
  • Drag from the code (the little cirle on the left hand side) into the xib 从代码(左侧的小圆圈)中拖动到xib中
  • If nothing else helps, restart Xcode 如果没有其他帮助,请重新启动Xcode

在此处输入图片说明

Check above image and just add your .swift class name in Identity Inspector 检查上面的图像,然后在Identity Inspector中添加您的.swift类名称

You need to do the following things to resolve this: 您需要执行以下操作来解决此问题:

  1. Add your Class Name inside UIViewController in storyboard. 在故事板中的UIViewController中添加类名称。

在此处输入图片说明

  1. Make sure your Module also None. 确保您的模块也没有。 If not select Module field and click "delete". 如果没有,请选择“模块”字段,然后单击“删除”。

Note: If this works then perfect you can go ahead with this. 注意:如果可以正常工作,那么您可以继续进行。 If not then, 如果没有,

  1. cmd+shift+"k" clean the code and do once again 1st and 2nd step. cmd + shift +“ k”清除代码,然后再次执行第一步和第二步。

  2. If still you faced same issue then Quit Xcode and reopen the project. 如果仍然遇到相同的问题,请退出Xcode并重新打开该项目。 This will work to resolve your issue. 这将解决您的问题。

Simple Thing Is First You have To Check Whether You Try To Creating Action Inside Class Or Outside Class If You try to Create Action Outside The Class It Not Taking, If You Creating Inside The Class It Will Works Even If You Are Creating Inside The Class Then Go For The Class Name gave The Class Name and Provide Storyboard Id Then Try It Will Definitely Works.简单的事情是首先你必须检查你是否尝试在课堂内或课堂外创建动作如果你尝试在课堂外创建动作它不会,如果你在课堂内创建它即使你在课堂内创建它也会起作用然后Go For The Class Name 给出了类名并提供 Storyboard Id 然后尝试它肯定会起作用。 Thank you......谢谢......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 圆形Rect按钮连接到ViewController.h - Round Rect Button connecting to ViewController.h Xcode 10.1 ViewController.h 与 ViewController.swift - Xcode 10.1 ViewController.h vs ViewController.swift 我在情节提要中的视图控制器将无法连接到viewcontroller.h文件或.m - My view controller in storyboard will not connect to the viewcontroller.h file or the .m 无法在UIImageView和ViewController.h之间创建连接 - Cannot create a connection between a UIImageView and the ViewController.h 无法将控件从WebView拖动到ViewController.h吗? - Can not control-drag from WebView to ViewController.h? AppDelegate.m和ViewController.h文件在我的xcode项目导航器中变成红色 - AppDelegate.m and ViewController.h files have turned red in my xcode project navigator 从另一个UIViewController的.xib文件在ViewController.h中创建IBOutlets - creating IBOutlets in ViewController.h from another UIViewController's .xib file ios localpush-在viewcontroller.h中声明的对象未在viewcontroller.m中重新协调 - ios localpush - object declared in viewcontroller.h is not reconized in viewcontroller.m 在ViewController.m中,如何通过字符串访问ViewController.h中声明的属性? - In ViewController.m, how can I access a property declared in ViewController.h by a string? 无法将 UILabel 连接到 ViewController - Cannot Connect UILabel to ViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM