我正在尝试显示不断滚动的“电影积分”。 VC代码如下所示。问题是动画开始前有大约12秒的延迟。动画开始后,呼叫之间不会重复延迟。在模拟器和iPhone5上可以看到相同的行为。
更感兴趣的是:当VC弹出时,应用程序会因cpu使用而疯狂(100%+)...我的笔记本电脑将达到200°。
显然这是没有开火的初始动画。如果完成块被注释掉,则不会发生任何动画。所以12秒延迟实际上是动画的第一次运行没有做任何事情,然后第二次调用实际上会在屏幕上发生一些事情。
有人可以解释我的错误或指向适当的文档。
- (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)];
}