Can't drag and drop item from storyboard to viewcontroller in xcode

前端 未结 13 1431
不知归路
不知归路 2021-02-02 10:54

I started working with xcode a few days ago, and today I tried to connect a textview from the main storyboard to the viewcontroller, but I figured out that its not working.

相关标签:
13条回答
  • 2021-02-02 11:32

    Hey I think you are not connected your storyboard viewController with your viewController class. check screen shot which "suhit" uploaded in his answer. I would like to tell you something more than it. When ever you need to connect any storyboard object with class.

    • first go to utility panel (right side) and then set class there.
    • after that you can connect your controls with class

    I hope it will help you.

    0 讨论(0)
  • 2021-02-02 11:33

    I had same problem, I realised I selected wrong story board. If you made app with default settings you will get two story boards (Main and Launch Screen). Labels on Launch screen story board cannot drag drop.

    0 讨论(0)
  • 2021-02-02 11:35

    For anyone who is new to XCode this picture might help more:

    Select the item in Main.storyboard from the right pane and then set the class for the view in the right pane. Now you can ctrl + drag into your class

    0 讨论(0)
  • 2021-02-02 11:36

    Check that the names on Viewcontroller identity inspector and the .h, .m files are the same. That worked for me

    0 讨论(0)
  • 2021-02-02 11:36

    Make sure that the item in question is connected to the file in which you want to control drag it to (specify the class in the identity inspector)

    0 讨论(0)
  • 2021-02-02 11:37

    Note that dragging to any point in your code doesn't necessarily work. If you've been unable to drag to create the connection in one spot of your code, try dragging to another spot. For me, I was trying to drag to add a connection in the middle of a function which didn't work. Dragging to the beginning line of a function or in between functions did work.

    Note: I'm on Xcode 9.1

    0 讨论(0)
提交回复
热议问题