我想在我的应用中支持VoiceOver
,但我有一些问题。我有UITableView
一些单元格,以支持VoiceOver
我执行以下操作:
cell.labelMorning.accessibilityTraits = UIAccessibilityTraitStaticText;
cell.labelAfternoon.accessibilityTraits = UIAccessibilityTraitStaticText;
//Without VoiceOver
cell.labelMorning.text = [NSString stringWithFormat:@"%@ - %@", model.startTimeM, model.endTimeM];
cell.labelAfternoon.text = [NSString stringWithFormat:@"%@ - %@", model.startTimeA, model.endTimeA];
//When VoiceOver is activated
cell.labelMorning.accessibilityLabel = [NSString stringWithFormat:@ %@ to %@ a Clock ",model.startTimeM,model.endTimeM];
cell.labelAfternoon.accessibilityLabel = [NSString stringWithFormat:@" %@ to %@ a Clock",model.startTimeA,model.endTimeA];
但是当我激活VoiceOver时,每个Label都会被读取两次,这是错误的吗?
答案 0 :(得分:0)
好的诀窍不是使用accessibilityLabel
而是使用accessibilityValue
!!
答案 1 :(得分:0)
为什么在设置标签文本后立即设置辅助功能标签?
您已经设置了accessibilityTrait,因此VoiceOver知道只读取该标签的文本。所以通过设置文本:
cell.labelMorning.text = [NSString stringWithFormat:@"%@ - %@", model.startTimeM, model.endTimeM];
您已经设置了accessibilityLabel了。我不确定这是否是您的源代码,但您可能希望向check if VoiceOver is running添加if语句,然后使文本包含'to'而不是' - '(如果是)。