0
我喜欢水平拖动该对象,而不是垂直的,这是目前杜安它:拖动对象垂直
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (CGRectContainsPoint(myObject.frame, location)){
CGPoint xLocation = CGPointMake(location.x, myObject.center.y);
myObject.center = xLocation;
}
}
谢谢,谢谢,谢谢你! – blacksheep 2010-05-08 12:10:26
不要感谢我;刚刚投票并接受答案。 ;-) – 2010-05-08 12:48:41
好的。但我仍然有一个小问题:拖动是在该对象之外使用该代码工作: - (void)touchesMoved:(NSSet *)与事件触及:(UIEvent *)事件UITouch * touch = [[event allTouches] anyObject] ; CGPoint位置= [touch locationInView:touch.view]; CGPoint xLocation = CGPointMake(location.x,myObject.center.y); myObject.center = xLocation; } 但不是上面的代码。 – blacksheep 2010-05-08 12:57:01