我有一个这样的数组Image1,Image2,Image3,Image4,Image5
每次水平滚动到图像视图时都会随机显示图像。
每个 An 每次生成新的系列。在单个图像视图上成功显示水平滚动。
Image2,Image1,Image3,Image5,Image4.
Image3,Image4,Image1,Image2,Image5.
Image4,Image2,Image3,Image1,Image5.
现在我希望图像视图直接显示双击图像。
如果这是在Image1上双击的图像序列
Image3,Image4,Image1,Image2,Image5.
然后我想Image View直接在他的位置显示Image1并自动向后添加Image3,Image4。Image2,Image5。在前面添加。
我怎么能这样做提前谢谢。
我试过这个
for(m=0; m<[FrontsCards count];m++)
{
ImgView.alpha=1;
ImgView.tag=m;
randIdx=arc4random()%[FrontsCards count];
NSString *imageName=[FrontsCards objectAtIndex:randIdx];
NSString *fullImageName=[NSString stringWithFormat:@"%@",imageName];
int padding=0;
CGRect imageViewFrame=CGRectMake(scrollView.frame.size.width*m+padding, scrollView.frame.origin.y, scrollView.frame.size.width-2*padding, scrollView.frame.size.height);
ImgView=[[UIImageView alloc]initWithFrame:imageViewFrame];
[ImgView setImage:[UIImage imageNamed:fullImageName]];
[scrollView addSubview:ImgView];
[ImgView setAccessibilityIdentifier:[FrontsCards objectAtIndex:randIdx]];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapImgView:)];
doubleTap.numberOfTapsRequired = 2;
doubleTap.delegate = self;
[self.ImgView setImage:[UIImage imageNamed:fullImageName]];
[self.ImgView setTag:randIdx];
[self.ImgView addGestureRecognizer:doubleTap];
self.ImgView.userInteractionEnabled=YES;
NSString *imageName1=[FrontsCards objectAtIndex:randIdx];
[newArray addObject:imageName1];
}
CGSize scrollViewSize=CGSizeMake(scrollView.frame.size.width*[FrontsCards count], scrollView.frame.size.height);
[scrollView setContentSize:scrollViewSize];
[self.view addSubview:scrollView];