Can't drag and drop item from storyboard to vi

2019-03-12 17:11发布

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.

I am able to ctrl+click to drag the item, but unable to place it in both viewcontroller.h and .m. I double checked that its viewcontroller and not UIViewcontroller, so this is not the case.

I'm using a Yosemite 10.10 mac.

Any kind of help would be appreciated.

11条回答
仙女界的扛把子
2楼-- · 2019-03-12 17:43

For beginners -- > make sure you have kept the "Ctrl" key pressed down while dragging and dropping onto the code. This can be easily missed.

查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-12 17:46

For me, the solution was to click on the "View" item in the dropdown menu that shows all the subviews for the controller.

Click on root view

Simply clicking on the controller image on the storyboard does not appear to properly "select" the controller for drag and drop abilities, the base view must be selected.

查看更多
SAY GOODBYE
4楼-- · 2019-03-12 17:51

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.

Connection was allowed here between functions

Connection was not allowed here inside the middle of a function

Note: I'm on Xcode 9.1

查看更多
\"骚年 ilove
5楼-- · 2019-03-12 17:54

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)

查看更多
Deceive 欺骗
6楼-- · 2019-03-12 17:54

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

查看更多
迷人小祖宗
7楼-- · 2019-03-12 17:55

Select the ViewController in storyboard and change the name of the ViewController to the name in the .h or .m file and then try ctrl+click and drag enter image description here

查看更多
登录 后发表回答