我有一个 ImageView ,我在它上面设置了其他 ImageView 并将它们放在不同的位置。我想在 mage view 上应用 FLIP ANIMATION。怎么办?当 if(i==1) 然后我的 imageview 被翻转。 img1
是我的 ImageView ,我想识别它。我在`imagearr中分配了52张图片
我的代码:
-(void)setCards
{
int k=0;
CGFloat dx = self.view.frame.size.width/2;
CGFloat dy = self.view.frame.size.height/2;
int cnt = [imagearr count];
for (int j=1; j<3; j++) // Number of cards
{
for (int i=1; i<5; i++) // Number of players
{
int rnd = (arc4random() % cnt)-1;
UIImage *img = [imagearr objectAtIndex:rnd];
UIImageView *img1 = [[UIImageView alloc] initWithImage:img];
CGRect frame = img1.frame;
frame.size.width = frameX;
frame.size.height = frameY;
[img1 setFrame:frame];
[img1 setTag:k+i];
[UIView beginAnimations:@"Move" context:nil];
[UIView setAnimationDuration:0.50];
if (i==1)
{
[img1 setCenter:CGPointMake(dx+100, dy+(j*15))];
}
if (i==2)
{
[img1 setCenter:CGPointMake(dx+(j*15), dy+60)];
}
if (i==3)
{
[img1 setCenter:CGPointMake(dx-130, dy-(j*15))];
}
if (i==4)
{
[img1 setCenter:CGPointMake(dx-(j*20), dy-95)];
}
[self.view addSubview:img1];
[UIView commitAnimations];
[img1 release];
}
k=k+10;
}
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
int t = [touch view].tag;
}
我仍然无法识别特定的 ImageView 。请帮我解决这个问题。
最佳答案
为单个 imageView 设置标签是最好的方法。使用标签,您甚至可以检测放置在表格 View 单元格内的多个图像,并设置用于选择单个标签的操作。
关于objective-c - 从多个 ImageView 中识别特定 ImageView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5854016/