ios - MPVolumeView 中的 showRouteButton 已弃用
问题描述
从 iOS 13 开始,MPVolumeView 中的 showRouteButton 已被弃用
let vv = MPVolumeView()
vv.showsRouteButton = false
警告是:
'showsRouteButton' was deprecated in iOS 13.0: Use AVRoutePickerView instead.
Apple 告诉我使用 AVRoutePickerView 进行路由,这没有任何意义,因为在我的情况下,我不想使用任何路由的东西,我只想隐藏它。似乎没有更多不推荐使用的方法来做到这一点。
如果它已被弃用,它应该默认隐藏,否则苹果应该允许我们隐藏它......
我可以说这是苹果 API 错误吗?
解决方案
现在只是为了删除警告和默认路由按钮,我在初始化MPVolumeView
.
if volumeView.value(forKey: #keyPath(MPVolumeView.showsRouteButton)) as? Bool == true { volumeView.setValue(false, forKey: #keyPath(MPVolumeView.showsRouteButton)) }
我通过键值路径检查值是否showsRouteButton
为true
并将其设置false
为。
推荐阅读
- php - 在 php 中替代 linux 中的 xxd 命令
- typescript - 这种类型的 const 函数表达式有什么作用?
- javascript - 如何将轮播箭头移得更远?
- go - Golang:如何仅使用 crypto/rand 生成随机浮点数
- java - 如何在 JPA hibernate 中获得与查询“select * from table where ...”相同的结果?
- r - 尝试通过 ODBC 错误将 R 连接到 Snowflake
- python - 从多索引熊猫数据帧的一级中选择多列
- graphql - GraphQL,在具有键值的对象数组中搜索
- html - 我如何将对象解析为角度数组?
- mybatis - Mybatis游标查询超过100k条记录