开发者

touches ended/After dragging is completed, i need to check, if the dragged image frame touches any of my 100 images frame

i have 100 UIViews in UIViewController class . i am dragging a separate imageView over my 100 UIviews.

when touches ended/dragging completed, i need to check, if the dragged image frame touches any of my 100 UIViews frame.

is there any way to check it. I have given tags to my each 100 UiViews.

Is there any easy way to get it the UIView Details.(than 100 开发者_JAVA百科switch conditions).

eg:

CGPoint touchEndpoint = [touch locationInView:self.view];
CGPoint imageEndpoint = [touch locationInView:imageview];
 if(CGRectContainsPoint([imageview frame], touchEndpoint))
 {


Add your UIViews to an NSMutableArray (myViews in the example) then you can do...

for(UIView *aView in myViews) {
  if(CGRectContainsPoint([myView frame], touchEndPoint)) {
    //DO STUFF
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜