我需要得到_propArrow(UIImageView的)每.1sec在任何時候的位置和使用的NSLog的方法(無效),以驗證runScheduledTaskXcode中得到的NSTimer對象的位置,每毫秒
,但不工作的每。1秒。
僅表示開始和動畫
的運動結束這是我的代碼:
- (void)viewDidLoad
{
[super viewDidLoad];
_propArrow.frame = CGRectMake(144, 291, 33, 71);
aTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(runScheduledTask) userInfo:nil repeats:YES];
}
- (void)runScheduledTask {
NSLog(@"Position: %@", NSStringFromCGRect(_propArrow.frame));
}
- (IBAction)fire:(id)sender {
[UIView animateWithDuration:1
delay:0
options:UIViewAnimationCurveEaseInOut
animations:^{
_propArrow.frame = CGRectMake(144, 0, 33, 71);
}
completion:^(BOOL finished){
}];
}
作品! 謝謝。這就是我真正期待的=) – Fabio
+1好點。 – Caleb