UIButton event 'Touch Up Inside' not working. 'Touch Down' works fine

牧云@^-^@ 提交于 2019-11-28 10:00:46

I'm sorry for being late but I have exactly the same problem. In my case it was a UITapGestureRecognizer assigned to parent view. So, it's good idea to check for recognizers as well.

You're releasing newViewController.

While the adding the newViewController.view as a subview will retain the view, the newViewController object will have a retain count of 0.

Bill Weakley

You mentioned saving; did you save both the xib and your MyViewController files after you made your changes? Often when something like this stops working for me, I find that I didn't save either the xib in IB or the class file in XCode.

Do you have any touch-event handlers implemented in your MyViewController's code?

It looks like your UIButton only receives touchesBegan event and the event gets cancelled by something before it could receive touchesEnded.

Something like UIScrollView usually does when it's deciding between touch that needs to be forwarded to it's subviews and a drag that should be handled by itself.

Lol well this was dumb solution, but in the xib I had it linked to buttonTouchUp outside, and that was causing the problem. Maybe this will help :)

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