我爲我的應用程序做了一個簡單的照片幻燈片,問題是我的代碼不會在最後一張圖像後重復圖像!這裏是我的代碼:iOS - 創建照片幻燈片
- (IBAction)start:(id)sender {
_button.hidden = YES;
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(photoCounter) userInfo:nil repeats:YES];
}
- (void)photoCounter {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.90];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
[self updatePhoto];
imageCount ++;
[UIView commitAnimations];
}
- (void)updatePhoto {
switch (imageCount) {
case 0:
_images.image = [UIImage imageNamed:@"wall1.jpg"];
break;
case 1:
_images.image = [UIImage imageNamed:@"wall2.jpg"];
break;
case 2:
_images.image = [UIImage imageNamed:@"wall3.jpg"];
break;
case 3:
_images.image = [UIImage imageNamed:@"wall4.jpg"];
break;
case 4:
_images.image = [UIImage imageNamed:@"wall5.jpg"];
break;
default:
break;
}
}