Question

I have seen countless tutorials on how to change the iPhone volume with a slider, button my application needs the volume be changed via two buttons, one up, one down. Here is my code:

    - (IBAction)volumeUp:(id)sender
    {
        [[musicPlayer setVolume:["current volume???" + 0.1]];
    }

    - (IBAction)volumeDown:(id)sender
    {
        [[musicPlayer setVolume:["current volume???" - 0.1]];
    }

Can anyone help? Thanks!

Was it helpful?

Solution

- (IBAction)volumeUp:(id)sender
{
    [[musicPlayer setVolume:musicPlayer.volume+0.1];
}

- (IBAction)volumeDown:(id)sender
{
    [[musicPlayer setVolume:musicPlayer.volume-0.1];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top