2013-05-20 207 views
0

如何發揮audioplayer時位置的速度大於20,計時開始五二個,忽然位置 速度(從20 T0 0速度下降)等於零,它播放音頻player.I試試這個,但沒有任何發生plz幫助我。這裏是我的代碼播放音頻播放時的位置速度降低

int i; 

- (void)locationUpdate:(CLLocation *)location{ 
    speedLabel.text = [NSString stringWithFormat:@"%.2fmph",[location speed]*2.236936284]; 

    if (location.speed >= 10) 
    { 
     [self performSelector:@selector(doThis) withObject:nil afterDelay:5]; 
     if (location.speed ==0) { 
      [audioPlayer play]; 
     } 
    } 
} 

-(void)doThis{ 
    if(i %5 == 0)  
    { 
     [CLController.locMgr startUpdatingLocation]; 
    } 
} 
+1

什麼增加「'我'」? –

回答

0

您的條件檢查將不會播放音頻。按給定的方式進行更改,

int i; 

- (void)locationUpdate:(CLLocation *)location{ 
    speedLabel.text = [NSString stringWithFormat:@"%.2fmph",[location speed]*2.236936284]; 

    if (location.speed >= 10) 
    { 
     [self performSelector:@selector(doThis) withObject:nil afterDelay:5]; 

    } 
    else if (location.speed ==0) { 
     [audioPlayer play]; 
    } 

} 

-(void)doThis{ 
if(i %5 == 0)  
{ 
    [CLController.locMgr startUpdatingLocation]; 
} 
} 
+0

由於它的工作:) – user2396021