i wonder if you guys have a sample code adding and move UIImageView on touch and also detect if there is an UIImageView there so i can't add UIImageView on top of it.
EDIT: clearer question 1. i wanna add an cups(UIImageView) when i touch the view but do not wan the cup(UIImageView) to stack.
- i wanna move the UIImageView but will bounce back to the original position if there is an UIImageView there so it will not stack the UIImageView already there.
thanks for reading my question and appreciated your helps
cheers
des
This should let you going…
Create two ivars in your header file:
The next two methods will be in your implementation file:
You can add a UIPanGestureRecognizer to the UIImageView to handle the dragging, as seen below.
Implement the following method:
In combination to the above, you can use CGRectIntersectsRect to find if it's intersecting another cup.
You would have to wrap the functionality to take into account all your cups but this gives you an idea a to how to accomplish what you're trying to do.