0
這裏是我的每一秒後調用manageAnimation代碼應用程序崩潰因嵌套的NSTimer和視圖切換
-(void)manageAnimation:(Properties *)prop
{
//if(bounceTimer.isValid)
// [bounceTimer invalidate];
bounceTimer = [NSTimer scheduledTimerWithTimeInterval:.05 target:self selector:@selector(animate) userInfo:nil repeats:YES];
}
-(void)animate{
static float t = 0;
float d = .5;
static float fValue = 0;
fValue = [self easeOutBounce:t andB:0 andC:34 andD:d];
[self setNeedsDisplay];
t += .5/10;
if(t > d){
[bounceTimer invalidate];
t = 0;
fValue = 0;
}
}
。當我點擊屏幕上的信息按鈕時,它會翻轉到設置屏幕,當我點擊完成按鈕在設置屏幕上返回到主屏幕應用程序崩潰。如果我註釋掉代碼
//bounceTimer = [NSTimer scheduledTimerWithTimeInterval:.05 target:self selector:@selector(animate) userInfo:nil repeats:YES];
然後應用程序工作正常。我不知道發生了什麼,我也發現當我切換到設置視圖時,這些定時器停止。
是的你是對的我需要self.bounceTimer =零;再開始之前。謝謝。整天浪費在這... – coure2011 2010-06-19 19:13:36