Question

I'm wanting to control the master volume of the iPhone with a UISlider. There is a way of doing it without code and I've forgot how to. So code or within the xib, how do I do this?

Thanks

Was it helpful?

Solution

You can try the following method: Place it in your XIB.

  1. Open the XIB where you want to place to slider into
  2. Add a UIView to your view
  3. Change the class identity from UIView to MPVolumeView
  4. Change backgroundColor to clear

OTHER TIPS

Assuming you already have an instance of the MPVolumeView class, you need to search its subviews to find the MPVolumeSlider view:

UISlider *volumeViewSlider;

// Find the MPVolumeSlider
for (UIView *view in [volumeView subviews])
{
   if ([[[view class] description] isEqualToString:@"MPVolumeSlider"]) 
   {
       volumeViewSlider = view;
   }
}

[volumeViewSlider setValue: 1.0f animated:YES];
[volumeViewSlider _commitVolumeChange];

Hope this helps you out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top