0

Im trying to do something very simple. Have a slider for volume that changes in width based on the devices' size or orientation.

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpVolumeView];
}

- (void) setUpVolumeView {
    // Volume control
    MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:self.myBoxForVolume.bounds];
    [self.myBoxForVolume addSubview:volumeView];
    //[volumeView sizeToFit];
}

I set the myBoxForVolume a certain distance from the left bound of the device's view and a certain distance from the right bound of the device's view in my storyboard. I would like the volumeView to have the same exact width as the myBoxForVolume (keeping in mind that myBoxForVolume can change in size), but for some reason I am unable to establish volumeView with the correct bounds.

redribben
  • 186
  • 1
  • 7

1 Answers1

3

Missing one line of code that mades all of this happen.

       volumeView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

Add a line like that to the setUpVolumeView method solves this issue of resizing.

redribben
  • 186
  • 1
  • 7