When a UITableView
是可编辑的,其UITableViewCells
允许用户在 VoiceOver 打开时执行自定义操作。当 VoiceOver 光标位于单元格上时,用户可以通过向上或向下滑动来听到可用的操作,然后通过双击屏幕上的任意位置来调用操作。我的单元格中只有两个可用操作:Delete(调用通常的单元格删除)和Default(调用单元格上的点击)。我的问题有两个:
有没有办法向单元格添加自定义 VoiceOver 操作?
默认情况下Delete即使表视图委托返回自定义标题,操作也会被读出为“删除”tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:
方法。如何让 VoiceOver 读出自定义操作标题?
There is simply no API for supplying custom element actions to VoiceOver. No UIAccessibility*
protocol provides anything for this to be possible. I guess you should file a radar if you need to add custom actions and hope Apple will implement it in some future version of iOS (or that it will appear in iOS 7 in a month).
UPDATE:从 iOS 8 开始,您可以设置/实现accessibilityCustomActions https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAccessibilityAction_Protocol/#//apple_ref/occ/instp/NSObject/accessibilityCustomActions属性返回您的数组UIAccessibilityCustomAction https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAccessibilityCustomAction_class/index.html对象(请注意,除了您提供的内容之外,VoiceOver 仍会在其 UI 中添加“激活项目”默认操作。):
self.accessibilityCustomActions = [
UIAccessibilityCustomAction(name: NSLocalizedString("Close", comment: ""), target: self, selector: "didPressClose")
]
...
@objc
func didPressClose() -> Bool {
...
}
像往常一样使用 Swift 和选择器,不要忘记添加@objc https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html#//apple_ref/doc/uid/TP40014216-CH4-XID_37如果您没有子类化,则属性为 Swift 中自定义操作的目标方法NSObject
/该方法是私有的,否则在尝试使用 VoiceOver 激活操作时,它不会执行任何操作并播放“已达到边界末尾”声音(至少在 iOS 8.2 和 8.3 上,我使用执行子类化的目标对象进行了测试NSObject
).
关于你的第二个问题 - 感觉像是一个错误,你可以再次提交雷达:-)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)