开发者

MPVolumeView in a UIAlertView?

开发者 https://www.devze.com 2022-12-30 08:59 出处:网络
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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消