单击纹理区域 [英] click on the texture area

查看:28
本文介绍了单击纹理区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个通过单击纹理对象来调用的函数.我刚刚弄清楚按钮动作是如何处理的.你能告诉我它是如何工作的吗?也许一些特殊的控件必须与纹理对象相对应?提前致谢)))

I'd like to create a function that will be called by clicking on texture object. I've just figured out how the button action is processed. Could you tell me plz how it works. Maybe some special controls have to be correspond to texture object? thanks in advance )))

推荐答案

我认为这是针对 iOS 的,点击意味着点击.以下代码将向任何 UIView 添加手势识别器:

I assume this is for iOS and by click you mean tap. The following code will add a gesture recognizer to any UIView:

    myView.userInteractionEnabled = YES;
    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    recognizer.numberOfTapsRequired = 1;
    recognizer.numberOfTouchesRequired = 1;

    [myView addGestureRecognizer:recognizer];

并像这样实现您的处理程序:

And implement your handler like this:

- (void)handleTap:(UITapGestureRecognizer *)sender {     
    if (sender.state == UIGestureRecognizerStateEnded) {
        //your code
    }
}

handleTap: 方法会在你的视图每次被点击时被调用.

The handleTap: method will be called every time your view receives a tap.

这篇关于单击纹理区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆