MPVolumeView 与 XCode 4(故事板)

发布于 2025-01-07 02:17:30 字数 104 浏览 5 评论 0原文

如何制作一个滑块来通过故事板调整设备的音量级别?我还没有找到任何与 XCode 4 相关的信息。 MPVolumeView 仍然是可行的方法吗?如果是这样,我该如何实施?

谢谢。

How do you make a slider that adjusts the volume level of the device with storyboarding? I haven't found any information on this relevant to XCode 4. Is MPVolumeView still the way to go? If so, how do I implement it?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一笑百媚生 2025-01-14 02:17:30

您仍然可以在 Xcode 4.x 和 iOS5 中使用 MPVolumeView。只需导入 MediaPlayer 框架(也在项目设置中链接到它)并使用类似以下内容:

MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0,0,120,15)];
[someView addSubview:volumeView];

这将为您提供拖动时会改变系统音量的滑块。

You can still use an MPVolumeView in Xcode 4.x and iOS5. Simply import the MediaPlayer framework (link to it in your project settings, too) and use something like this:

MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0,0,120,15)];
[someView addSubview:volumeView];

This will give you the slider that will change system volume when dragged.

黑白记忆 2025-01-14 02:17:30

如果您想使用滑块,您可以将一个滑块添加到视图中并将其链接到相应视图控制器中的操作。动作看起来像这样:

- (IBAction)volumeSliderChanged:(id)sender
{
    UISlider *slider = (UISlider *)sender;
    float newVolume = slider.value;
    // Set new volume
}

If you want to use a slider, you can add one to your view and link it to an action in the corresponding view controller. The action looks like this:

- (IBAction)volumeSliderChanged:(id)sender
{
    UISlider *slider = (UISlider *)sender;
    float newVolume = slider.value;
    // Set new volume
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文