UITouch - 事件没有响应

发布于 2024-09-08 21:48:51 字数 363 浏览 7 评论 0原文

我有以下一段代码,我希望在触摸事件上运行:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch;
    touch=[touches anyObject];
    CGPoint point=[touch locationInView:self.view];

    if (CGRectContainsPoint([billTotal frame],point))
    {
        [self pickerShow];
    }
}

它没有被执行,你知道我做错了什么吗?

问候, 斯蒂芬

I have the following piece of code that I'm expecting to run on a touch event:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch;
    touch=[touches anyObject];
    CGPoint point=[touch locationInView:self.view];

    if (CGRectContainsPoint([billTotal frame],point))
    {
        [self pickerShow];
    }
}

Its not being executed, any ideas what I'm doing wrong?

Regards,
Stephen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吾家有女初长成 2024-09-15 21:48:51

您是否启用了对视图的触摸?

我相信 UIImageView 默认情况下禁用用户交互。

如果您有视图的 .xib 文件,您可以通过选择视图,按 CMD + 1 并选中 User Interaction Enabled 在 Interface Builder 中启用触摸,

您可以在代码中执行以下操作像这样

myView.userInteractionEnabled = YES;  

Did you enable touches on the view?

I believe UIImageView has user interaction disabled by default.

If you have a .xib file for the view you can enable touches in Interface Builder by selecting the view, pressing CMD + 1 and checking User Interaction Enabled

In code you can do it like this

myView.userInteractionEnabled = YES;  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文