だからここに私のコードがあります:
- (IBAction)run:(id)sender {
animationPointer = 0;
self.animationArray = [[NSMutableArray alloc] init];
UIView *allViews = [[UIView alloc]
initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
for (int i = 0; i < [self.paths count]; i++) {
[allViews addSubview:[self createAnimation:[self.paths objectAtIndex:i]]];
[self.animationArray addObject:allViews];
}
timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(animateTurn)
userInfo:nil repeats:YES];
}
- (void)animateTurn {
UIView *tempView = [self.animationArray objectAtIndex:animationPointer];
[self.view addSubview:tempView];
for (UIImageView *view in tempView.subviews) {
[[tempView.subviews objectAtIndex:animationPointer] startAnimating];
}
animationPointer++;
if (animationPointer >= [self.animationArray count]) {
[timer invalidate];
}
}
createAnimation
ご想像のとおり、完全にアニメーション化された が返されますUIImageView
。計画では、それぞれにいくつかを配置してUIView
から、すべてをアニメーション化し、UIView
0.5 秒後に次のアニメーションを繰り返します。今のところ、それぞれに 1 つだけありUIView
ます。
ただし、 で animateTurn を呼び出すとNSTimer
、アニメーションは表示されません。通常の方法でメソッドを呼び出すと、それらは表示されますが、関数も[self animateTurn]
何もありません。NSTimer
performSelector
これに関するヘルプ(またはより良い方法の提案)はありますか?
編集: 関数が実際にトリガーされており、startAnimating (BOOL/NSLog でチェック) を含むコードが実行されていることに言及する必要があります。何も表示されていません。