使用以下代码对多个对象进行拖动时,当我触摸对象时对象会抖动,
-(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];
}
我的代码有什么问题,是否有其他方法可以拖动,如果视图中还包含一个对象?请帮我解决这个问题
答案 0 :(得分:0)
我认为如果你正在谈论更多的对象一次拖动那么你应该从你触摸的方法中删除返回