结合使用UISwitch和UITableViewCell进行VoiceOver交互 [英] Combine UISwitch and UITableViewCell for VoiceOver interaction

查看:129
本文介绍了结合使用UISwitch和UITableViewCell进行VoiceOver交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在日历中,当您创建新事件时,如果在启用VoiceOver的情况下点击全天"单元格,则Siri会说打开/关闭全天切换按钮,双击以更改设置".实际上,双击将切换该开关.另外,不可能仅点击切换开关本身-您必须与单元格本身进行交互才能切换开关,该开关本身不是可访问的元素.

In Calendar, when you create a new event, if you tap on the All Day cell with VoiceOver enabled, Siri says "All Day switch button on/off, double tap to change setting". And indeed double tapping will toggle the switch. Also, it's not possible to tap on just the toggle switch itself - you have to interact with the cell itself to toggle the switch, the switch itself is not an accessible element.

在我的应用中,我具有与标签和开关完全相同的设置.但是,当我在启用VoiceOver的情况下点击单元格时,它仅读取标签,因此盲人用户不知道该单元格中有一个拨动开关.如果他们点击开关本身,则可以与之交互,因此与日历"应用中的设置相反.

In my app I have the exact same setup with a label and a switch. But when I tap the cell with VoiceOver enabled it only reads the label so the blind user has no idea there's a toggle switch in that cell. If they tap the switch itself then they can interact with it, so it's the opposite of the setup in the Calendar app.

如何获得与Apple相同的行为?我需要某种方式将开关组合到单元格中,以便VoiceOver突出显示单元格时会同时读取它们,然后当他们双击时,应该切换开关,而且我不确定该如何完成设置.谢谢!

How can I obtain the same behavior that Apple implemented? I need some way to combine the switch into the cell so VoiceOver reads both upon highlighting the cell, then when they double tap it should toggle the switch, and I'm not sure how that setup can be accomplished. Thanks!

推荐答案

要实现所需的行为,而不是将UISwitch放置在单元格的contentView中,请通过编程将其添加为accessoryView.然后,单元格和开关的行为将与使用VoiceOver时完全一样,就像在日历中一样.

To implement the desired behavior, instead of placing the UISwitch in the contentView of the cell, add it as the accessoryView programmatically. Then the cell and switch will behave exactly as expected when using VoiceOver, exactly as it does in Calendar.

这篇关于结合使用UISwitch和UITableViewCell进行VoiceOver交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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