gpt4 book ai didi

ios - 启用 VoiceOver 的 UIButton 语音帮助

转载 作者:行者123 更新时间:2023-11-29 12:14:28 25 4
gpt4 key购买 nike

我想问一下如何在启用 VoiceOver 的情况下按需设计旁白帮助。

我有这样的代码来创建 UIButton:

_myLocationButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[_myLocationButton setImage:[UIImage imageNamed:@"my_location_icon"] forState:UIControlStateNormal];
_myLocationButton.accessibilityLabel = @"My location";
_myLocationButton.accessibilityHint = @"Double tap to hear where You are, in which zone or near zone and floor information in building";
[_myLocationButton addTarget:self
action:@selector(myLocationButtonPressed)
forControlEvents:UIControlEventTouchUpInside];

现在在 myLocationButtonPressed 方法中我有这样的代码:

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, positionDescription);

我的问题是。当我在 myLocationButton 处于事件状态时尝试双击时,VoiceOver 只会说:“我的位置”。我想要的是双击后我想听到 positionDescription 而不是按钮 accessibilityLabel。我知道 myLocationButtonPressed 方法正在调用,但由于未知原因,发布 UIAccessibilityAnnouncementNotification 事件什么都不做,我也听不到任何声音。

谁能给我一些建议,告诉我如何处理这类问题。

最佳答案

我发现要让公告始终如一地被宣读出来,唯一的方法就是延迟发布通知。此功能应该有所帮助。

- (void)postVoiceOverAnnouncement:(NSString*)message withDelay:(int)seconds {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(seconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, @"This will get read out");
});
}

即使添加了 starts media session 特征,某些内容仍然会打断公告。您必须注意的是延迟的时间长度。如果有人继续在您的应用程序中滑动,他们可能会中断通知。不过,由于在一个可适当访问的应用程序中,此信息应该在其他地方可用,他们应该能够再次找到它。这当然只是一个有用的公告,以免将注意力转移到毫无戒心的 VoiceOver 用户身上:)。

我注意到您的代码的另一个问题:

_myLocationButton.accessibilityHint = @"Double tap to hear where You are, in which zone or near zone and floor information in building";

首先,非常感谢包含如此详细的提示!但是,您不应包含“双击以...”部分。用户知道如何通过 VoiceOver 与按钮交互。这是与之交互的唯一方式吗?或者也可以在外部键盘上按回车键?其他一些假设的 AT,其中选择手势是其他一些交互……这个提示对使用盲文板的人有多大用处???只需告知用户与对象交互的后果,让 AT 处理其余部分。

关于ios - 启用 VoiceOver 的 UIButton 语音帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32334096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com