Is it possibe to put an MPVolumeView in a UIAlertView?
I have tried to put it inside of it, but it does not display. It may be the sizeToFit
or initWithFrame:
part?
Is there a way of testing if the MPVolumeView
is actually being created?
Here's the code I initialize both the UIAlertView
and MPVolumeView
with:
UIAlertView *volumeAlert = [[UIAlertView alloc] initWithTitle:@"Volume" message开发者_JAVA百科:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:volumeAlert.bounds];
[volumeAlert addSubview:volumeView];
[volumeAlert sizeToFit];
[volumeAlert show];
[volumeAlert release];
[volumeView release];
Take a look at MPVolumeSettingsAlertShow()
Displays an alert panel for controlling the system volume.
I think initing the VolumeView with the VolumeAlert's frame would cause problems. Since VolumeAlert's frame is never being set (before VolumeView's frame is set), you can't depend on it being any size.
UIAlertView
is a subclass of UIView
, and UIView
has a convenient addSubview:
method. Have you tried that?
You might like to check out this recent blog post from Jeff LaMarche, should fill your needs - Custom Alert Views
精彩评论