9

当 aUITableView可编辑时,它UITableViewCells允许用户在 VoiceOver 开启时执行自定义操作。当 VoiceOver 光标位于单元格上时,用户可以通过向上或向下滑动来听到可用的操作,然后通过双击屏幕上的任意位置来调用操作。我的单元格中只有两个可用的操作:删除(调用通常的单元格删除)和默认(调用单元格上的点击)。我的问题有两个:

有没有办法将自定义 VoiceOver 操作添加到单元格?

默认情况下,即使表视图委托在方法中返回自定义标题,删除tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:操作也会被读出为“删除” 。如何让 VoiceOver 读出自定义动作标题?

4

2 回答 2

12

根本没有用于向 VoiceOver 提供自定义元素操作的 API。没有任何UIAccessibility*协议为此提供任何可能。我想如果您需要添加自定义操作并希望 Apple 将在未来的 iOS 版本中实现它(或者它会在一个月内出现在 iOS 7 中),我想您应该提交一个雷达。

更新:从 iOS 8 开始,您可以设置/实现该accessibilityCustomActions属性以返回对象数组UIAccessibilityCustomAction(请注意,除了您提供的内容之外,VoiceOver 仍会在其 UI 中添加“激活项目”默认操作。):

self.accessibilityCustomActions = [
    UIAccessibilityCustomAction(name: NSLocalizedString("Close", comment: ""), target: self, selector: "didPressClose")
]
...
@objc
func didPressClose() -> Bool {
    ...
}

与 Swift 和选择器一样,@objc如果您没有子类NSObject化/该方法是私有的,请不要忘记将属性添加到 Swift 中自定义操作的目标方法,否则在尝试使用 VoiceOver 激活操作时,它不会做任何事情并播放“到达边界结束”的声音(至少在 iOS 8.2 和 8.3 上,我用做 subclass 的目标对象进行了测试NSObject)。

关于你的第二个问题 - 感觉就像一个错误,你可以再次提交雷达:-)

于 2013-05-01T12:06:24.690 回答
3

iOS 8 增加了对应用定义的自定义操作的支持。来自UIAccessibility.h

/*
 Return an array of UIAccessibilityCustomAction objects to make custom actions for an element accessible to an assistive technology.
 For example, a photo app might have a view that deletes its corresponding photo in response to a flick gesture.
 If the view returns a delete action from this property, VoiceOver and Switch Control users will be able to delete photos without performing the flick gesture.
 default == nil
 */
@property (nonatomic, retain) NSArray *accessibilityCustomActions NS_AVAILABLE_IOS(8_0);
于 2014-11-24T15:58:31.170 回答