1

我正在寻找一种在 iOS 中一次拖动图像的方法(而不是一次拖动一堆图像)。我已经问过这样的问题并且确实得到了一些答案,但是没有用。我相信它没有用,因为我的情况可能与预期不同,这就是我发布相同问题的原因。我听说手势可能有用,但我尝试了很多不同类型的代码,但没有得到任何结果。请帮忙。

最亲切的问候。

cowKeys = [[NSArray alloc] initWithObjects:@"cow",@"cow1",@"cow2",@"cow3",nil];

-(void) dealcows {

    while (current cow <= 11) {

        currentName = [NSMutableString stringWithFormat:@"%@.png", [cowsShuffled        objectAtIndex:currentCard] ];
        totalcowrValue = totalDealerValue + [[dictionary valueForKey:[cowsShuffled objectAtIndex:currentcow]] intValue];

        UIImageView *imageView = [[UIImageView alloc] init];

        if (currentcow== 1){

            if (autoPlay == YES){
                imageView.image= [UIImage imageNamed:currentName];
            } else {
                imageView.image= [UIImage imageNamed:currentName];
            }


            cow = (UIImageView *)[self.view viewWithTag:11];
            cow.userInteractionEnabled = YES;
            cow1 = (UIImageView *)[self.view viewWithTag:1];
            cow1.userInteractionEnabled = YES;
        }
    }
}

- (void)touchesMoved:(NSSet *)set withEvent:(UIEvent *)event {
    CGPoint a = [[set anyObject] locationInView:self.view];
    CGPoint r = [[set anyObject] locationInView:self.view];
    cow.center = a;

    cow1.center = r;

}  
4

1 回答 1

0

添加UIPanGestureRecognizer到要移动的 imageView 并将 @selector 添加到该UIPanGestureRecognizer. 相信我,我已经用 CALayers 和 subviews 完成了这个动人的事情。它像黄油一样工作。

于 2012-09-11T09:18:11.327 回答