JPSVolumeButtonHandler icon indicating copy to clipboard operation
JPSVolumeButtonHandler copied to clipboard

Is there more to getting this working than the readme says?

Open dtirer opened this issue 10 years ago • 2 comments

I'm just doing a quick test prototype to make sure that I can in fact respond to volume buttons presses. I installed VolumeButtonHandler via Cocoapods, ensured that my project sees it and implemented the following as a test in ViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];

    self.outputLabel.text = @"";

    self.volumeHandler = [JPSVolumeButtonHandler volumeButtonHandlerWithUpBlock:^{
        self.outputLabel.text = @"  Up!  ";
    } downBlock:^{
        self.outputLabel.text = [self.outputLabel.text stringByAppendingString:@"  Down!  "];
    }];
}

When I load it up on my iPhone6, It doesn't print anything to my label upon pressing vol up or down

dtirer avatar Nov 25 '15 23:11 dtirer

Me too, don't know what's going on here

X140Yu avatar Jan 18 '17 09:01 X140Yu

I had the same issue a while ago and found that you need to call: [self.volumeHandler start]; after you initialize the volumeHandler. (I'm doing it in swift, so I'm guessing about the method signature for Obj-C). You should also do: [self.volumeHandler stop]; self.volumeHandler = nil; in something like the viewDidDisappear() or similar, depending on your usage.

creitz avatar Jan 18 '17 16:01 creitz