2
我在UIView
中添加了UIImageView
作爲子視圖,然後我用UITouchesBegan
中的以下代碼移動此子視圖。旋轉它後移動子視圖,不正確的作品
CGPoint newTouch = [[touches anyObject] locationInView:self];
CGPoint lastTouch = [[touches anyObject] previousLocationInView:self];
float xDif = newTouch.x - lastTouch.x;
float yDif = newTouch.y - lastTouch.y;
translate = CGAffineTransformMakeTranslation(xDif, yDif);
[self setTransform: CGAffineTransformConcat([self transform], translate)];
然後我用下面的代碼旋轉這個子視圖。
self.transform=CGAffineTransformRotate(self.transform, RADIANS(180));
在這個階段,一切都很好.. 但是當我嘗試再一次將我的子視圖,它在相反的方向,即移動,當我想向上移動它,它向下移動。
有什麼想法?建議?
嗯謝謝gschandler .. !!! –
這可以是一個更好的解決方案,但我正在尋找.. http://dl.dropbox.com/u/22783696/DraggableImage.zip –