【问题标题】:Set tappable focus on button element of UIAlertView during VoiceOver - UIAccessibility在 VoiceOver 期间在 UIAlertView 的按钮元素上设置可点击焦点 - UIAccessibility
【发布时间】:2014-12-31 10:37:11
【问题描述】:

我打算在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 正在运行,我希望可点击的焦点位于按钮上,而不是标题元素上。所以当显示警报视图时我会这样做:

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

但是,按钮的可访问性标签被 VoiceOver 读出(“这是我的按钮”),但可点击的焦点没有设置在按钮上,而是保留在 UIAlertView 的标题元素上

【问题讨论】:

    标签: ios objective-c uialertview voiceover uiaccessibility


    【解决方案1】:

    您确定要与 VoiceOver 战斗吗?用户能够非常快速地导航,部分原因在于 VoiceOver 遍历用户界面的一致性。尽量不要通过更改默认设置来妨碍他们。

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

    【讨论】:

    • 感谢您的回答。你的建议是有效的,我已经实现了[self performSelector:@selector(readOutEmergencyCallAnnouncement) withObject:self afterDelay:4.0f]; 来运行UIAccessibilityPostNotification,它基本上与dispatch_async() 一样。无论如何,它仍然没有设置“可点击”焦点。就像你说的,我可能必须回到客户端才能不破坏 iOS 约定
    猜你喜欢
    • 1970-01-01
    • 2018-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 1970-01-01
    • 2011-01-24
    • 2021-02-17
    相关资源
    最近更新 更多