Search code examples
ioscocoa-touchuiviewtouchesbegan

UIView's touches not being recognized


The touchesBegan: is not being called by my TextSelection class. TextSelection is a UIView subclass which I added as a subview of ReaderContentPage, also a UIView. ReaderContentPage is s subview of ReaderContentView, a UIScrollView. And this ReaderContentView is inside ReaderViewController, a UIViewController. Here is an illustration to make it easier to understand.

enter image description here

Now my problem is this. touchesBegan: and touchesMoved: is not recognized in TextSelect. I enabled the userInteraction, used the UIPanGestureRecognizer, but none of those worked. Now when I tried to do this: [self.ReadContView addSubView:txtSel] instead of this [self.ReadContView.ReadContPage addSubView:txtSel], the touches are recognized. But I have to add it in ReaderContentPage and not in ReaderContentView for some reason. So can anyone explain to me why touchesBegan and touchesMoved are not called when I add TextSelect in ReaderContentPage?


Solution

  • UserInteraction is disabled by default on UIImageView, have you a UIImageView in your readContentPage?