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;
}
是否要將圖像拖放到Xcode中? –
不,我想觸摸圖片並拖動它。因此虛空觸動了方法。 –
爲什麼你在方法中設置兩個imageViews的中心? – TedCheng