Iphone 多目标拖动
当使用以下代码拖动多个对象时,当我触摸对象时,对象正在抖动Iphone 多目标拖动,iphone,ios6,uitouch,Iphone,Ios6,Uitouch,当使用以下代码拖动多个对象时,当我触摸对象时,对象正在抖动 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; if ([touch view] == img1) { CGPoint location = [touch locationInView:touch.view]
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
if ([touch view] == img1)
{
CGPoint location = [touch locationInView:touch.view];
img1.center = location;
return;
}
if (touch.view == img2)
{
CGPoint location = [touch locationInView:touch.view];
img2.center = location;
return;
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}
我的代码中有什么问题,是否有其他方法可以拖动,如果视图包含一个或多个对象?请帮助我解决这个问题我认为如果您要同时拖动多个对象,那么您应该删除触摸begain方法的返回值我有多个对象,但我一次拖动一个,虽然移除了tat retun,但它也不能正常工作,