【发布时间】: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