Reputation: 26223
I have a controller that uses an animated UIImageView to display a sequence of 30 512 x 512 frames. When I run the application the view quickly does the following.
- (void)viewDidLoad {
[super viewDidLoad];
[[self imageView] setAnimationImages:[[self dataModel] framesForLOOP]];
[[self imageView] setAnimationDuration:2.5];
[[self imageView] setAnimationRepeatCount:1];
[[self imageView] startAnimating];
NSLog(@"MARKER_001");
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"MARKER_002");
}
This all works fine but what I am trying to work out is that after viewDidLoad:
is called there is a 2 second delay before viewDidAppear:
is called (between MARKER_001 and MARKER_002).
I was thinking there might be a delay setting up the frames NSArray
or after calling setAnimationImages:
or maybe after startAnimating
.
Is there anyway to reduce/remove this delay, I would prefer to preload the animation at startup and take a hit there rather than having the delay when the viewController loads as it makes the button that fires the segue to instantiate the new controller feel laggy.
Upvotes: 0
Views: 2019
Reputation: 62686
Just a few ideas:
Upvotes: 2
Reputation: 130172
Note that even if you call startAnimating
in viewDidLoad
, the animation won't start there. You can't get an animation running in a controller which has not been not displayed yet.
You should call the startAnimating
in viewDidAppear
instead.
Two seconds delay between these two methods is not anything strange. The delay can be much longer or shorter, depending on what happens inside your application. Measuring the time between two methods which are not connected doesn't make sense. What about measuring how much time the individual methods take?
If anything is laggy, you should probably paste all the code that happens between the user action and the moment when everything is displayed and the lag happens.
Upvotes: 0