Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a UISlider to change volume

Tags:

cocoa-touch

What's the best way to use a UISlider to change the volume of the iPhone in an app?


I've tried using that Bill (Using a UISlider to change volume)

But nothing appears on the screen using the code:

MPVolumeView *volumeView = [[[MPVolumeView alloc] initWithFrame:
                                CGRectMake(0, 0, 215, 22)] autorelease];
volumeView.center = CGPointMake(150,375);
[volumeView sizeToFit];
[self.view addSubview:volumeView];
like image 713
Domness Avatar asked Jan 20 '09 20:01

Domness


2 Answers

I've just found a very easy way. Instead of coding, just 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

Voila!

PS: Tested it on a device with iPhone OS 3.0. As lostInTransit stated before, it won't work on the simulator.

like image 165
Dshutsi Avatar answered Nov 24 '22 02:11

Dshutsi


Using a UISlider to change volume

^ I tried that lostintransit, however this is not changing the ringer volume. It comes up on the iphone screen, but doesn't change anything. Even using the demo project provided.

like image 29
Domness Avatar answered Nov 24 '22 04:11

Domness