简体   繁体   中英

Different Tap Recognizer for Subviews

I am using a UIView as a container to hold a UILabel and an UIImageView .

I want both the UILabel and UIImageView to have a UITapRecognizer BUT: The Different functions.

    let gesture3 = UITapGestureRecognizer(target: self,
    action: #selector(chatViewController.clickOnGroupImage(_:)))
    imageView.addGestureRecognizer(gesture3)

    let gesture2 = UITapGestureRecognizer(target: self,
    action: #selector(chatViewController.clickOnButton(_:)))
    labelView.addGestureRecognizer(gesture2)

Now after putting both as subviews to my container, I am not able to click them (It worked fine, when I tested both methods just on a single Container).

Any Ideas?

确保userInteractionEnabledtrue对你所申请的手势(意见imageViewlabelView你的情况),也使集装箱的用户交互。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM