【发布时间】:2009-06-11 06:25:14
【问题描述】:
如果我有一个 UIImageView 并想知道用户是否点击了图像。在 touchesBegan 中,我执行以下操作,但始终以第一个条件结尾。窗口处于纵向模式,图像位于底部。我可以在窗口的右上角点一下,仍然进入第一个条件,这似乎很不正确。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:touch.view];
if(CGRectContainsPoint(myimage.frame, location) == 0){
//always end up here
}
else
{ //user didn't tap inside image}
值是:
location: x=303,y=102
frame: origin=(x=210,y=394) size=(width=90, height=15)
有什么建议吗?
【问题讨论】:
标签: objective-c iphone cocoa-touch uiimageview core-graphics