MPVolumeView in a UIAlertView?

我的未来我决定 提交于 2019-12-20 07:38:28

问题


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:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:volumeAlert.bounds];

[volumeAlert addSubview:volumeView]; 

[volumeAlert sizeToFit];

[volumeAlert show];
[volumeAlert release];
[volumeView release];

回答1:


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.




回答2:


Take a look at MPVolumeSettingsAlertShow()

Displays an alert panel for controlling the system volume.




回答3:


UIAlertView is a subclass of UIView, and UIView has a convenient addSubview: method. Have you tried that?




回答4:


You might like to check out this recent blog post from Jeff LaMarche, should fill your needs - Custom Alert Views



来源:https://stackoverflow.com/questions/2829234/mpvolumeview-in-a-uialertview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!