2013-05-20 204 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