Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kingsapo

macrumors member
Original poster
Jun 10, 2010
58
4
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;
}

}
 
hey, thanks for the response! I actually posted this on Apple's developer forums, and the answer the person gave was good and detailed, though my knowledge of Objective-C is somewhat limited, so I didn't get most of it. So thanks again for your response, and I'll definitely come back to this answer once I hit my Objective-C book again.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.