开发者

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

开发者 https://www.devze.com 2023-04-10 06:44 出处:网络
i have 100 UIViews in UIViewController class . i am dragging a separate imageView over my 100 UIviews.

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

精彩评论

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