So, I have an iOS7 application in which I use MPVolumeView so that the user can control the volume level. I have a route button hidden on this particular MPVolumeView and use another MPVolumeView when the slider is disabled as an AirPlay icon.
My application supports orientation in both portrait and landscape orientation, and the volume slider is different in two different modes.
If the view is first initialized in landscape mode, then MPVolumeView will change correctly.
However, when the view is initialized in portrait mode, and then I turn to landscape mode, EVERYTHING in the application changes / moves, except that the MPVolumeView only moves and it does not get shorter as it should.
I use custom images in MPVolumeView , and if I delete custom images for the track, this problem will go away.
Here is the code used to initialize MPVolumeView
self.volumeView = [[MPVolumeView alloc] initWithFrame:CGRectZero]; self.volumeView.showsRouteButton = NO; self.volumeView.layer.borderColor = [[UIColor redColor] CGColor]; self.volumeView.layer.borderWidth = 1.0f; if (AT_LEAST_IOS7) {
And in layoutSubviews, I move / scale it:
self.volumeView.frame = CGRectIntegral(CGRectMake(controlsLeft + kEdgeToSliderSideWidth, volumeTop, controlsWidth - (2 * kEdgeToSliderSideWidth), volumeSize.height));
Here's what it looks like when a view starts in portrait mode: (total width of 640 pixels)

And when it rotates to Landscape, it looks like this: (total width 568 pixels)

Does anyone have any ideas?
ios ios7 uiview mpvolumeview
jrwagz
source share