以编程方式增加音量 [英] Increase volume programmatically

查看:119
本文介绍了以编程方式增加音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我的应用中以编程方式增加和减少应用量,而不是使用MPVolumeView。

i want in my app to increase and decrease the app volume programmatically from the code and not to use MPVolumeView.

推荐答案

您无法以编程方式更改卷,这是一个深思熟虑的设计选择。想象一个应用程序不断将音量设置为最高级别,这不仅会令人讨厌,甚至可能会损坏您的耳朵,如果您戴着入耳式耳机。

You cannot change the volume programmatically, and that's a deliberate design choice. Imagine an app that constantly sets the volume to the highest level, that would not only be annoying but could even damage your ears if you're wearing in-ear headphones.

您应该向 MPVolumeView 显示用户这样他就可以自己改变音量。您可以遍历其子视图层次结构并搜索 UISlider 并调整其外观,就像使用任何普通的UISlider一样。这样您就可以将 MPVolumeView 改编为您的应用程序设计。

You should show an MPVolumeView to the user so he can change the volume himself. You can walk its subview hierarchy and search for the UISlider and adjust its appearance like with any normal UISlider. This way you can adapt the MPVolumeView to your app design.

这篇关于以编程方式增加音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆