0

是否可以将 MPVolumeView 放在 UIAlertView 中?

我试图它放在里面,但它没有显示。它可能是sizeToFitinitWithFrame:部分?有没有办法测试它MPVolumeView是否真的被创建了?

这是我初始化UIAlertView和的代码MPVolumeView

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];
4

4 回答 4

6

看一眼MPVolumeSettingsAlertShow()

显示用于控制系统音量的警报面板。

于 2011-01-04T13:20:41.650 回答
1

UIAlertView是 的子类UIView,并且UIView有一个方便的addSubview:方法。你试过吗?

于 2010-05-13T19:07:25.167 回答
1

我认为用 VolumeAlert 的框架初始化 VolumeView 会导致问题。由于从未设置 VolumeAlert 的框架(在设置 VolumeView 的框架之前),因此您不能依赖它是任何大小。

于 2010-05-19T02:01:02.710 回答
0

您可能想查看 Jeff LaMarche 最近的这篇博客文章,应该满足您的需求 -自定义警报视图

于 2010-05-19T01:47:43.773 回答