I'm trying to display a continuously scrolling 'movie credits'. The VC code is shown below. The problem is that there is a ~12 second delay before the animation starts. Once the animation starts, the delay is not repeated between calls. The same behavior is seen on the simulator and a iPhone5.
An added bit of interest: When the VC pops, the app goes crazy with cpu use (100%+)... my laptop will hit 200°.
Apparently it's the initial animation that is not firing. If the completion block is commented out, no animation ever happens. So the 12 second delay is actually the first run of the animation not doing anything then the second invocation actually makes something happen on the screen.
Can someone explain what I'm doing wrong or point me to the appropriate docs.
- (void)loopCredits
{
CGRect startFrame = _creditsView.frame;
CGRect endFrame = CGRectMake(0, -568, 320, 568);
[UIView animateWithDuration:10.0
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
self.creditsView.frame = endFrame;
}
completion:^(BOOL finished) {
self.creditsView.frame = startFrame;
[self performSelector:@selector(loopCredits) withObject:nil afterDelay:0.0];
}
];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = NO;
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// [self loopCredits];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self createInfoString];
self.creditsView.attributedText = self.text;
[self loopCredits];
}
- (void)createInfoString
{
NSString* path = [[NSBundle mainBundle] pathForResource:@"InfoPageText" ofType:@"plist"];
NSURL* pathURL = [[NSURL alloc] initFileURLWithPath:path];
NSArray* temp = [NSArray arrayWithContentsOfURL:pathURL];
NSUInteger strLength = [[temp objectAtIndex:0] length];
self.text = [[NSMutableAttributedString alloc] initWithString:[temp objectAtIndex:0]];
UIFont* font = [UIFont fontWithName:@"Chalkduster" size:18.0f];
UIColor* textColor = [UIColor colorWithRed:250.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1];
[_text addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, strLength)];
[_text addAttribute:NSForegroundColorAttributeName value:textColor range:NSMakeRange(0, strLength)];
}