2010-09-13 65 views
1

我想仅在指定的位置获取UIImageView上的触摸事件。如何在指定的CGRect上获取触摸事件

UITouch *touch=[touches anyObject]; 
CGPoint currentPoint=[touch locationInView:CGRectMake(0,0,100,100)]; 

CGRectMake(0,0,100,100)在具体的位置我需要touche事件,是否有可能。 怎么办?

在此先感谢。

回答

3

在的touchesBegan和touchesMoved:

UITouch *touch=[touches anyObject]; 
CGPoint currentPoint=[touch locationInView:self]; 

CGRect testRect = CGRectMake(0,0,100,100); 

if(CGRectContainsPoint(testRect, currentPoint)) { 
    //For if you are touching the 100 x 100 rectangle... 
} 
+0

感谢thyrgle ....它的做工精细 – kiran 2010-09-13 06:31:26

+1

如果它的正常工作,你应该给回答了接受他们的答案的人给予信贷。有关更多信息,请参阅stackoverflow常见问题:http://stackoverflow.com/faq#howtoask – Greg 2010-09-13 21:14:36

+0

@GreglnYeg。我对这个人没有任何想法。我只需点击现在的复选标记。这是我的荣耀吗? – kiran 2010-09-14 04:58:51