SteMa SteMa - 1 month ago 18
Swift Question

MPVolumeView in Wrapper-UIVIew

I have a really strange behaviour when trying to add a MPVolumeView to my current view. Without adding constraints in the interfacebuilder to the wrapper uiview, everything works fine. But when I add constraints to the wrapper view in interface builder I am not able to change the volume anymore.

self.volumeView = MPVolumeView(frame: self.volumeSliderWrapper.bounds)
self.volumeSliderWrapper.addSubview(self.volumeView!)
self.volumeView?.sizeToFit();
self.volumeView?.autoresizingMask = [.FlexibleHeight, .FlexibleWidth];


Thats the code to add the MPVolumeView to my WrapperView.

The Airplay Button, which is part of the MPVolumeView works as aspected but only the button on the volume slider does not react on movements (also the volume doesnt change). Any ideas?

I am using XCode8/Swift2.3

Answer

OK for everybody having the same problem. I ended with setting the type of the wrapper UIView to MPVolumeView, so I don't have a wrapper anymore. Seems the best way to get rid of the problem.