I'm replicating an MPMediaPlayerView using AVPlayer so I can add some functionality to it. I've created an UIView with play/pause and I display it on a touch and then set a timer to hide it as per the HeadsUpUI sample code. I've added a MPVolumeView to it to adjust the volume.
That works fine, except that if you're sliding the volume around, my parent view has no idea you are still interacting with a subview and hides itself when the timer fires. So you're still adjusting the volume, but the slider is no longer there.
What I'd ideally like to know is when the touch has ended on the view and all subviews. Is there a way to do this?
The only solution I can think of is to walk the subviews of MPVolumeView and when I find the slider, observe the tracking property to know when it is done tracking. But that doesn't handle someone hold downing on a button for a long time. I'd really like to find a general solution to this.
TIA
Add a gesture recognizer to the MPVolumeView. Have the gesture recognizer call a method in your view that resets the timer.
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, 88, 320, 30)];
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(volumeAdjusted:)];
recognizer.cancelsTouchesInView = NO; // this line is VERY important
[volumeView addGestureRecognizer:recognizer];
[self.view addSubview:volumeView];
[volumeView release];
-(void)volumeAdjusted:(UIGestureRecognizer *)recognizer {
// reset timer
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With