0

使用以下代码拖动多个对象时,当我触摸对象时,对象正在晃动,

   -(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];
     }

我的代码有什么问题,还有其他方法可以拖动吗?如果视图包含更多对象?请帮我解决这个问题

4

1 回答 1

0

我认为,如果您正在谈论一次要拖动的更多对象,那么您应该从 touch begin 方法中删除返回

于 2013-01-12T07:41:16.120 回答