Can't create IBAction ctrl-dragging UIButton to ViewController (Xcode Version 7.2)

蹲街弑〆低调 提交于 2019-12-13 13:31:50

问题


In the middle of my creating the app, xcode quit allowing me to ctrl-drag UIButtons to VCs for creating IBActions. This happens on every VC (nine in all). It does allow for creating Outlets, though. (Pls see image -> no Action selection is showing)

xcode Version 7.2 (7C68) build target is ios9.

Is there a way to fix this?


回答1:


Some things to try:

Make sure you are using one of the "Sent Events" to create the IBAction - not a Triggered Segue (that will do what you are describing) or other connection.

Try connecting not just via Ctr-drag, but via the right click menu or connections menu.

Try adding the code:

@IBAction func myAction()
{ }

... a clear circle should appear, which can be connected via dragging to the button in IB. This will create a Touch Up Inside event.

Finally, restart your project and try again.



来源:https://stackoverflow.com/questions/35058462/cant-create-ibaction-ctrl-dragging-uibutton-to-viewcontroller-xcode-version-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!