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 a开发者_JS百科nd UIimages.
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).
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
.
精彩评论