I know that this question must have been answered plenty of times already, but I have no idea why the touchesBegan:
is not called in my UIView
.
Before I added it in my app, I made a trial project to do some tests. What I did was subclass a UIView
where the touchesBegan:
is implemented and add this as a subview of another view. The superview has a button which shows the subclassed UIView
once clicked. Everything works as expected.
However, when I did the same thing in my existing app, the touchesBegan:
method, as well as the touchesMoved:
, were never called. Can anyone explain what could be preventing the methods from being called?
I just found the answer to this. I realised that the superview of the UIView
has the userInteraction
set to disabled (which is the default value). So when I enabled the userInteraction
of the superview, the touches are now recognised.
In my case background = UIColor.clearColor()
was the reason why touchesBegan
was not called. Its obviously not called on transparent elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With