1

私はiOSで一度に1つずつ画像をドラッグする方法を探しています(一度にたくさんではありません)。私はすでにこのような質問をし、いくつかの答えを得ましたが、うまくいきませんでした。私の状況は予想とは異なる可能性があるため、うまくいかなかったと思います。そのため、同じ質問を投稿しています。ジェスチャーが機能する可能性があると聞きましたが、さまざまな種類のコードを試しましたが、結果が得られませんでした。助けてください。

よろしくお願いします。

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

移動するimageViewに追加UIPanGestureRecognizerし、それに@selectorを追加しUIPanGestureRecognizerます。私はCALayersとサブビューでこの感動的なことをしたと信じています。バターのように機能します。

于 2012-09-11T09:18:11.327 に答える