0

場所の速度が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];
    }
}
4

1 に答える 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];
}
}
于 2013-05-20T04:36:48.290 に答える