I am having trouble with the following code.
If I use this code and run it on a simulator, it only displays the first two images in the transition array. If I launched it on Iphone, it will show me only the first shot. Also, he does not repeat the pictures.
What am I doing wrong?
- (void)viewDidLoad{
[super viewDidLoad];
welcomePhoto = [NSArray arrayWithObjects:@"Bild.jpeg",@"Bild1.jpeg", @"Bild2.png", nil];
imageView.image = [UIImage imageNamed:[welcomePhoto objectAtIndex:0]];
[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(transitionPhotos) userInfo:nil repeats:YES];
}
-(void)transitionPhotos{
int photoCount;
if (photoCount < [welcomePhoto count] - 1){
photoCount ++;
}else{
photoCount = 0;
}
[UIView transitionWithView:self.imageView
duration:2.0
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{ imageView.image = [UIImage imageNamed:[welcomePhoto objectAtIndex:photoCount]]; }
completion:NULL];
}
source
share