我正在开发一个从 NSMutableArray 加载图像的应用程序。它生成随机图像并将其加载到 iOS 中的 UIImageview。我想在加载后将该数组保存到另一个数组中,我该怎么做。提前致谢。
我的代码如下。
//FrontsCards 是我的数组
for(m=0; m<[FrontsCards count];m++)
{
ImgView.alpha=1;
ImgView.tag=m;
NSLog(@"Img View Tag %d",ImgView.tag);
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]];
NSLog(@"full image name %@",fullImageName);
NSLog(@"Image Name = %@", fullImageName);
[self.ImgView setTag:randIdx];
[self.ImgView addGestureRecognizer:doubleTap];
self.ImgView.userInteractionEnabled=YES;
}
CGSize scrollViewSize=CGSizeMake(scrollView.frame.size.width*[FrontsCards count], scrollView.frame.size.height);
[scrollView setContentSize:scrollViewSize];
[self.view addSubview:scrollView];