0

私は 6 つの uiimageviews を持っています。たとえば、img1 - img6 とします。img1をタッチしてドラッグすると動きます。しかし、img1 をドラッグして他の uiimageviews に近づくと、img1 の動きが止まり、それに近づいた img が動き始めます。これは、画像をゆっくりドラッグしたときではなく、非常に速くドラッグしたときに発生します。また、ドラッグはそれほどスムーズではありません...... :(

これが私がこれまでに行ったことです...

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
if (CGRectContainsPoint([self.firstImg frame], [touch locationInView:nil]))
{
    [self.view bringSubviewToFront:self.firstImg];
    self.firstImg.center = [touch locationInView:nil];
}
else if (CGRectContainsPoint([self.secondImg frame], [touch locationInView:nil]))
{
    [self.view bringSubviewToFront:self.secondImg];
    self.secondImg.center = [touch locationInView:nil];
}
else if (CGRectContainsPoint([self.thirdImg frame], [touch locationInView:nil]))
{
    [self.view bringSubviewToFront:self.thirdImg];
    self.thirdImg.center = [touch locationInView:nil];
}
else if (CGRectContainsPoint([self.fourthImg frame], [touch locationInView:nil]))
{
    [self.view bringSubviewToFront:self.fourthImg];
    self.fourthImg.center = [touch locationInView:nil];
}
else if (CGRectContainsPoint([self.fifthImg frame], [touch locationInView:nil]))
{          
    [self.view bringSubviewToFront:self.fifthImg];
    self.fifthImg.center = [touch locationInView:nil];
}
else if (CGRectContainsPoint([self.sixthImg frame], [touch locationInView:nil]))
{        
    [self.view bringSubviewToFront:self.sixthImg];
    self.sixthImg.center = [touch locationInView:nil];
}
}
4

1 に答える 1