【问题标题】:Play Audio Player when location speed decreases定位速度降低时播放音频播放器
【发布时间】:2013-05-20 04:21:50
【问题描述】:

如何在定位速度大于 20 时播放音频播放器,计数时间开始五秒以及突然定位时 速度(速度从 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];
    }
}

【问题讨论】:

  • 什么增量“i”?

标签: ios objective-c ios5 cllocation


【解决方案1】:

您的条件检查不会播放音频。按照给定的方式进行更改,

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];
}
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-31
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    • 2012-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多