Touch in UIView is not called

I know this question needs to be answered many times, but it really gives me a headache right now.

touchesBegan:not called in my UIView. Before I added it to my application, I first did a test project. In the trial project, everything worked perfectly. What I did was a subclass of UIView where it is implemented touchesBegan:, and adds this UIView as a subquery of another view. This second view has a button that shows a subclassified UIView after clicking. Again, everything works exactly the way I want.

Now that I have done the same in my existing application, the method touchesBegan:(and also touchesMoved:) is never called. Can someone explain to me why? I just don’t understand why he was never called.

+5
source share
3 answers

I just found the answer to this question. I forgot to mention that the view is inside another UIView that is disabled by the user (it is disabled by default). Therefore, when I turned on userInteraction of this view, strokes are now recognized.

+7
source

In my case, there background = UIColor.clearColor()was a reason why touchesBeganit was not called. It is clearly not called transparent elements.

+1
source

... . , touchesBegan override : ViewController! , , !;)

, IF subviews, ... , "" .

, . , , .

, , - :

- ( )

-

- ,

ES.

:

//The last view outlet
@IBOutlet weak var ContainerView: UIView!

viewDidLoad():

let tap = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
self.ContainerView.addGestureRecognizer(tap)

:

func handleTap(recognizer: UITapGestureRecognizer){
    self.view.endEditing(true)
}
0

All Articles