iPhone SDK:Trouble Dragging a UIImageView

ⅰ亾dé卋堺 提交于 2019-12-04 09:49:09

You can try to subclass UIImageView and implement touchesBegan: and touchesMoved: on it directly. Then in InterfaceBuilder select your subclass for the UIImageView.

alt text http://img.skitch.com/20090728-xetretcfubtcj7ujh1yc8165wj.jpg

Oh yes, now you will need to set the user interaction again...

You need to enclose it in begin / commit Animation sequences at least in your timer thread:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.02]  /* 0.02 seconds suration*/

/* move pig coordinates here */

[UIView commitAnimations];

Save the new movement in touchesMoved and then process them in the timer thread.

You can use an UIView category to make it draggable and define the draggable area: https://github.com/rtoshiro/TXDragAndDrop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!