UITouch - 事件没有响应
我有以下一段代码,我希望在触摸事件上运行:
- (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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否启用了对视图的触摸?
我相信 UIImageView 默认情况下禁用用户交互。
如果您有视图的 .xib 文件,您可以通过选择视图,按
CMD + 1
并选中User Interaction Enabled
在 Interface Builder 中启用触摸,您可以在代码中执行以下操作像这样
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 checkingUser Interaction Enabled
In code you can do it like this