Hello all! Alright, so my problem is I am trying to make a simple app that will allow the user to touch and drag a picture of a fan (named fan). As of now, the app will have the fan picture follow a finger, even if the touch did not begin on the fan. I wanted the program to need the user to begin the touch on the fan image, and otherwise have it do nothing. Code is posted below, and any help is appreciated!
@implementation Drag_3ViewController
-(void) touchesMoved
NSSet *)touches withEvent
UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:touch.view.superview];
if (CGRectContainsPoint(touch.view.frame, location)) {
fan.center = location;
}
}
@implementation Drag_3ViewController
-(void) touchesMoved
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:touch.view.superview];
if (CGRectContainsPoint(touch.view.frame, location)) {
fan.center = location;
}
}