简体   繁体   中英

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. 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.

图2

Any idea how can I do this?

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

Sometimes Xcode behaves a little "buggy". Some of the following might help:

  • You should ensure that your project compiles without error, otherwise Xcode frequently doesn't recognize you D&D
  • Drag from the code (the little cirle on the left hand side) into the xib
  • If nothing else helps, restart Xcode

在此处输入图片说明

Check above image and just add your .swift class name in Identity Inspector

You need to do the following things to resolve this:

  1. Add your Class Name inside UIViewController in storyboard.

在此处输入图片说明

  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.

  2. If still you faced same issue then Quit Xcode and reopen the project. 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. Thank you......

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM