I need to change the pictures in a loop in the UIImageView . If something about the standard methods of animation, which UIImageView owns UIImageView I vkurse, but it is necessary to make a loop. Here is my code:
- (void)startAnimating { for (int i = 0; i < allImages.count; i++) { sleep(1); [self changeImageByIndex:i]; } } - (void)changeImageByIndex:(NSInteger)index { [imageView setImage:[allImages objectAtIndex:index]]; } in the array allImages are all the pictures. do not pay attention to sleep(1) either - this is a temporary crutch that will be removed) the fact that the body of the cycle is actually executed once every 1 second, BUT! The image is shown only the latest. Those. during the cycle, nothing is noticeable, but at the end of the OCP! and we see the last picture. Why are they not updated?
for, Max wrote everything correctly. In real projects you shouldn't do that. For such a task, either start the animation inUIImageView, or by timers and, if you want to do it right, thenCADisplayLink(something like the timers on update on the screen) - Gralex