本文介绍了iPhone - 让VoiceOver宣布更改标签文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用iPhone上的VoiceOver在标签上更新时宣布更新文本?

Is it possible using VoiceOver on the iPhone to announce the updated text on a label if it changes?

这类似于ARIA中的实时区域。

This would be analogous to a live-region in ARIA.

谢谢。

推荐答案

你可以让VoiceOver宣布你的任何文字喜欢:

You can make VoiceOver announce any text you like with:

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, @"Your text");

如果标签在更新后立即公布其文本,只需扩展 UILabel 并覆盖 setText 方法。

If a label should announce its text as soon as it is updated, simply extend the UILabel and override the setText method.

.h文件:

@interface UIVoicedLabel : UILabel {

}

@end

及其实施:

#import "UIVoicedLabel.h"

@implementation UIVoicedLabel

- (void) setText:(NSString *)text {
    // Set the text by calling the base class method.
    [super setText:text];
    // Announce the new text.
    UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, text);
}

@end

这对我来说非常合适: )

This worked perfectly for me :)

这篇关于iPhone - 让VoiceOver宣布更改标签文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 16:21