【问题标题】:View with UITapGestureRecognizer and two buttons使用 UITapGestureRecognizer 和两个按钮查看
【发布时间】:2012-10-14 09:47:22
【问题描述】:

我有一个 UIView 自定义类(m、h、xib),上面有两个按钮。如果我点击它,这个视图应该会收到触摸,所以我实现了一个 UITapGestureRecognizer:

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:customElementView action:@selector(customElementPressed:)];
[customElementView addGestureRecognizer:tapGesture];
[tapGesture release];

这个视图上什至有两个按钮,每个按钮上都有一个在 touchUpInside 动作中实现的 IBAction。

我的问题是这两个按钮没有收到动作,每次我点击它们时,都会调用 UIView 的 TapGesture 方法。我怎样才能以某种方式“强制”这些按钮来捕捉水龙头?

【问题讨论】:

    标签: uiview uibutton uitapgesturerecognizer


    【解决方案1】:

    请在发布新问题之前使用搜索功能。 搜索 UITapGestureRecognizer 和 UIButton,应该会给你答案:

    https://stackoverflow.com/a/3348532/312312

    或者您可能想先尝试这种方法:

    https://stackoverflow.com/a/8891030/312312

    【讨论】:

    • 谢谢,第二个解决了我的问题。我不知道我以前怎么找不到它,但是我浏览了已经提出的问题。无论如何,谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-05
    • 2015-07-02
    • 1970-01-01
    • 1970-01-01
    • 2021-12-31
    相关资源
    最近更新 更多