问题:如何将自定义VoiceOver辅助功能标签或提示添加到应用程序图标徽章编号?
For example ,当iOS设置 Accessibility > VoiceOver
变为 On
时,VoiceOver会朗读屏幕上的项目 . 对于App Store和Mail图标,将大声朗读以下内容:
App Store图标,VoiceOver说:“App Store.2可用更新 . 双击打开 . ” VoiceOver邮件图标说:“邮件.1未读消息 . 双击打开 . ”
But ,对于我正在进行的项目,VoiceOver读出是通用的,并不完全有用:
我的应用程序图标,VoiceOver说:“我的应用程序.123项新项目 . 双击打开 . ”
短语 "... new items" 太模糊,不准确,我确信必须有一种方法可以通过自定义字符串来改变它,通过设置 accessibilityLabel
, accessibilityHint
或类似的东西来使其更好地读取 .
但究竟如何在Swift代码?
非常感谢 .
Additional observation:
使用模拟器辅助功能检查器,VoiceOver值显示为 Label
- "My App"和 Value
- "123 new items" . 在代码中更新了我尝试将 accessibilityValue
设置为自定义的东西 - "123 custom description." . 但仍然没有运气,VoiceOver继续阅读“我的应用程序.123 new items . 双击打开 . ”
Why isn't VoiceOver reading the custom badge value as expected?
Code:
以下方法将红色圆圈App图标徽章编号添加到我的应用程序图标:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let badgeCount: Int = 123
let application = UIApplication.sharedApplication()
if #available(iOS 8.0, *) {
//// iOS 8, iOS 9, iOS 10
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Badge], categories: nil))
} else {
//// iOS 7
}
application.applicationIconBadgeNumber = badgeCount
application.accessibilityValue = "123 custom description."
}
}
1 回答
看来这是现在的"Apple-only"功能... source
通过API文档挖掘,尚未公开支持't seem to be any identifier that can set this for you, and I therefore think it' . 它可能已经被报道,但报告这个请求Apple永远不会受到伤害 .
对不起,这可能不是你所希望的答案! :/