I have an application with drag and drop a UIView
feature. I should only let 3 drags and not more than that. How do I keep track of the number of drags? I tried incrementing a counter in touchesBegan()
, but the counter got incremented on tapping the view also. I want it to be increased only when I drag the view. Also can you provide a snippet for dragging and dropping a small UIView
into another view on the top. I don't know if I have used the right method.
My code:
(void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
[self.view setMultipleTouchEnabled:NO];
UITouch *touch = [touches anyObject];
if ([touch view] == option1View || [touch view] == option2View ||
[touch view] == option3View ||[touch view] == option4View) {
CGRect frame = [[touch view] frame];
if(counter == 1){
frame.origin.x = 10;
frame.origin.y = 90;
}
[[touch view] setFrame:frame];
I incremented my counter in touched began. I checked that if condition for 3 cases of counter