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

前端 未结 5 1586
旧巷少年郎
旧巷少年郎 2020-12-09 19:45

I\'ve got a UIButton in a UIView, which is in a UIViewController that I\'ve allocated and inited from a .xib file.

When hooking an IBAction up to the \'Touch Down\'

相关标签:
5条回答
  • 2020-12-09 20:08

    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.

    0 讨论(0)
  • 2020-12-09 20:15

    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.

    0 讨论(0)
  • 2020-12-09 20:15

    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.

    0 讨论(0)
  • 2020-12-09 20:20

    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.

    0 讨论(0)
  • 2020-12-09 20:28

    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 :)

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