如何在定位速度大于 20 时播放音频播放器,计数时间开始 5 秒,当突然定位速度(速度从 20 t0 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];
if (location.speed ==0) {
[audioPlayer play];
}
}
}
-(void)doThis{
if(i %5 == 0)
{
[CLController.locMgr startUpdatingLocation];
}
}