画外音:UIButton 的标签在激活时会重复

问题描述 投票:0回答:1

我有一个 UIButton,当焦点放在按钮上时,VoiceOver 会说出按钮的标签,当双击激活它时,VoiceOver 会再次说出按钮的标签。 无论如何,我可以防止双击按钮时再次说出按钮的标签吗?

ios accessibility voiceover
1个回答
0
投票

如果您想将焦点更改到另一个元素,您可以使用 UIAccessibility post 和 .screenChanged。如果您不想切换焦点,您可以使用 .announcement 来指示应用程序正在执行某些操作...可以像“忙”一样简单。用户单击您的按钮后调用这些。

lazy var masterViewButton: UIBarButtonItem = {
    let masterViewButton = UIBarButtonItem(
        image: UIImage(),
        style: .plain,
        target: self,
        action: #selector(self.masterViewButtonPressed))
    return masterViewButton
}()

@objc
func masterViewButtonPressed(_ sender: UIBarButtonItem) {
// use one these.
UIAccessibility.post(notification: .screenChanged, argument: myView)
UIAccessibility.post(notification: .announcement, argument: "busy")
// do some stuff here.
}

你甚至可以使用计时器来重复一些事情

let accessibilityTimer = Timer.scheduledTimer(withTimeInterval: 20, repeats: true) { timer in
            UIAccessibility.post(notification: .announcement, argument: "loading")
        }

当你将间隔设置得很小时,你可以阻止任何事情被说出......我不喜欢这样。因为这意味着当该计时器运行时,您的应用程序中不会读取任何内容。这可能是最适合您的解决方案。

let accessibilityTimer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { timer in
    UIAccessibility.post(notification: .announcement, argument: "")
}

完成后...结束计时器

accessibilityTimer.invalidate()

根据您的需要,您可以选择以下任何选项。

© www.soinside.com 2019 - 2024. All rights reserved.