I originally added an MPVolumeView dynamically on to a page...
#import "MediaPlayer/MPVolumeView.h"
.
.
-(IBAction) handleVolumeButtonClicked:(id) sender {
if (volumeView == nil) {
volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(25, 378, 270, 30)];
[self.view addSubview:volumeView];
[volumeView release];
} else {
[volumeView removeFromSuperview];
volumeView = nil;
}
}
But for some reason I started getting reports of the application crashing when dynamically adding the volume component.
To work around this, I decided to try and add the component to the view via the XCode designer, but then I realised that I didn't know how to do this!
I dragged an 'Object' from the template to the Object palette first, but then I found that I couldn't add it to the view. So I scrapped that idea and then dragged the 'View' object directly on to the .xib view.
Once the component was added, I tried to change the 'Custom Class' to 'MPVolumeView', but the view just rendered an empty rectangle. Running the code in the simulator failed to render anything.
Does anyone know what steps I am missing to add a class to the view that doesnt already exist in the palette?
Adding a generic UIView and setting the custom class to MPVolumeView does indeed work. Make sure to do the following: