我有 100 张图像存储在数组中,并使用随机显示在单个图像视图中swipe gesture.
在双击时,我想将该特定图像存储在NSUserDefault
. 谁能帮助我实现这一目标。
我试过这个
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]];
[[NSUserDefaults standardUserDefaults]setObject:UIImagePNGRepresentation(@"") forKey:@""];
提前致谢。