Silent
Silent

Reputation: 681

how to detect touch on UIView with UIimage ontop of it?

i want to use a UIview and a UIImage ontop of it with a text box and button i want the user to drag it when the UIview or anything in the view is touched, what would be the best way to implement this method?

the UIView is on a single View Controller and using Interface Builder to make my UIviews and UIimages.

Upvotes: 0

Views: 2460

Answers (2)

shosti
shosti

Reputation: 7422

You need to subclass UIView and implement

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event,

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event,

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event, and

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event.

Upvotes: 0

Tobias Klüpfel
Tobias Klüpfel

Reputation: 716

Have a look at the Apple Sample "MoveMe" http://developer.apple.com/iphone/library/samplecode/MoveMe/Introduction/Intro.html

The class MoveMeView in there is draggable. (There's also some superfluous animation going on, but the dragging is there).

Upvotes: 1

Related Questions