我是 iOS 新手。
我正在开发一个有 2 的应用程序NSMutableArray
。我想将数组图像加载到ImageView
.
我想拍摄第一张图片并将其添加到ImageView
. 当使用向左滑动时,我想将数组中的下一个图像添加到一个新图像中ImageView
并显示它。如果他们向后滑动,请加载上一个等
我还想将第二个数组中的图像加载到ImageView
用户双击图像时。
我试过这个
AppDelegate * delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
NSLog(@"%lu",(unsigned long)[delegate.FrontsCards count]);
ImgView= [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
//ImgView.image=[UIImage imageNamed:@"cloub1.png"];
int random=arc4random()%[delegate.FrontsCards count];
NSLog(@"%d",random);
ImgView.image=[delegate.FrontsCards objectAtIndex:random];
[self.view addSubview:ImgView];
currentImageIndex = 0;
ImgView.userInteractionEnabled = YES;
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[[self view] addGestureRecognizer:recognizer];
[super viewDidLoad];
}
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer
{
NSLog(@"Swipe received.");
AppDelegate * delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
for(int i=0;i<52;i++)
{
NSLog(@"%d",i);
ImgView.image=[delegate.FrontsCards objectAtIndex:i];
}
ImgView.image=[UIImage imageNamed:@"cloub3.png"];
}
谁能帮我做这件事?先感谢您。