0

This is cute ... I've copied the code from Apple's docs -- adding the lines about isUserInteractionEnabled for good measure -- but my MPVolumeView slider is totally unresponsive when I try and drag it. It does move appropriately when I click the volume button.

   myVolumeViewParentView.backgroundColor = UIColor.clear
    let myVolumeView = MPVolumeView(frame: myVolumeViewParentView.bounds)
    myVolumeViewParentView.isUserInteractionEnabled = true
    myVolumeView.isUserInteractionEnabled = true
    myVolumeViewParentView.addSubview(myVolumeView)

When I look in the view debugger, I don't see any other view in front of it.

Any ideas? I saw a posting about this a couple of years ago, but there was no answer. Here's hoping the second time's the charm ...

Michael Rogers
  • 1,318
  • 9
  • 22
  • Hi, did u find a solution? I have the same issue. I suspect it might be because i have another view that has a gesture recognizer but i'm not sure. – FredFlinstone Sep 22 '17 at 14:41
  • No. I gave up and used MPVolumeSettingsAlertShow() instead, and I actually prefer it (it doesn't clutter up the UI when the user doesn't need it -- which is 99% of the time). – Michael Rogers Sep 22 '17 at 18:26
  • Thanks for your reply. I found the solution. I've put it in the answer. – FredFlinstone Sep 25 '17 at 07:24

1 Answers1

4

I had the same issue. What solved it for me was to give the volume view a height constraint if you don't explicitly set it's frame.

To test this do:

myVolumeView.clipsToBounds = true

If the volume view doesn't show than you know there's no frame. You than need to set it's frame or give it a height constraint.

FredFlinstone
  • 896
  • 11
  • 16