开发者

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

开发者 https://www.devze.com 2022-12-27 09:35 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消