ios - 在 VoiceOver 期间将可点击焦点设置在 UIAlertView 的按钮元素上 - UIAccessibility

标签 ios objective-c uialertview voiceover uiaccessibility

我打算在 UIAlertView 的按钮元素上使用 UIAccessibilityLayoutChangedNotification 设置辅助功能焦点(可点击焦点)。为了保存对按钮的引用,在下面的代码中实现了它:

UIAlertView *alert = [[[UIAlertView alloc] init] autorelease];
alert.delegate = self;
[alert setTitle:@"Title"];
[alert setMessage:@"Message"];

[alert addButtonWithTitle:@"Button"];
UIButton *yesButton = [alert.subviews lastObject];
[yesButton setHidden:NO];

myButton = [[UIButton buttonWithType:UIButtonTypeCustom] autorelease];
[myButton retain];
[alert addSubview:myButton];
[alert show];

[myButton setAccessibilityLabel:@"This is my button"];
[myButton setFrame:yesButton.frame];

[alert show];

如果 VoiceOver 正在运行,我希望可点击的焦点位于按钮而不是标题元素上。所以我在显示警报 View 时这样做:

if(UIAccessibilityIsVoiceOverRunning()){
    UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, myButton);
}

但是,按钮的辅助功能标签由 VoiceOver 读出(“这是我的按钮”),但可点击的焦点并未设置在按钮上,而是保留在 UIAlertView 的标题元素上>

最佳答案

你确定要对抗 VoiceOver 吗?用户能够非常快速地导航,部分原因是 VoiceOver 遍历用户界面的一致性。尽量不要通过更改默认值来妨碍他们。

也就是说,您可以通过在警报 View 出现后发布布局更改通知来覆盖默认的 VoiceOver 焦点。尝试从您的 UIAlertViewDelegate-didPresentAlertView: 执行此操作.您可能还需要在发布通知之前稍等片刻,以确保 View 已完成显示并且 VoiceOver 已注意到。 dispatch_async() 非常适合此目的。

关于ios - 在 VoiceOver 期间将可点击焦点设置在 UIAlertView 的按钮元素上 - UIAccessibility,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27719912/

相关文章:

ios - Swift:如何在中断时停止调用 scheduleBuffer 完成处理程序?

ios - 在完成 block 中使用 iOS Swift 泛型

objective-c - 在 OpenGL 中绘制法线的正确方法?

iphone - 进行 Facebook 集成时出错

iOS UIAlertView 权限 Alpha 阴影

ios - 如何重新加载 UIAlertView 消息

IOS:如果 UISlider 更改其值,则仅显示一次警报

ios - iOS 上的 TDD 与调试

ios - Swift 4 转换 - 类型 'NSLayoutConstraint' 没有成员 'FormatOptions' 。什么是正确的电话?

objective-c - 使用 Objective-C 函数设置整数