我正在以编程方式构建iOS的UINavigationContoller
,并且在使其完全可访问方面遇到了问题。在loadView
中,我创建了主要的UIView
并将其设置为不可访问:
- (void)loadView
{
CGRect viewRect = [[UIScreen mainScreen] applicationFrame];
UIView *tmp = [[UIView alloc] initWithFrame:viewRect];
[tmp setIsAccessibilityElement:NO];
然后我添加额外的UIViews
,这些视图仅包含背景图像,并将它们设置为不可访问。所有视图和控件都添加到上面创建的“tmp”UIView
中。以下是一个“背景”视图示例:
UIImage* microphone = [UIImage imageNamed:@"microphone.jpg"];
UIView* microphoneView = [[[UIView alloc] initWithFrame: CGRectMake(0,0,viewRect.size.width, microphone.size.height)] autorelease];
[microphoneView setBackgroundColor:[UIColor colorWithPatternImage:microphone]];
[microphoneView setIsAccessibilityElement:NO];
[tmp addSubview:microphoneView];
最后我添加了一个UIButton
,UILabel
和UIButtonBarItem
。 我将它们放在视图层次结构的顶部。我为它们添加了可访问性标签和特征。这是UIButton
:
self.recordImage = [UIImage imageNamed: @"record_button.png"];
self.stopRecordImage = [UIImage imageNamed: @"stop_button.png"];
self.recordButton.accessibilityTraits |= UIAccessibilityTraitStartsMediaSession;
self.recordButton = [[UIButton alloc ] initWithFrame: CGRectMake((viewRect.size.width - recordImage.size.width)/2 , (microphone.size.height + (grayBkg.size.height - recordImage.size.height)/2), recordImage.size.width, recordImage.size.height)];
[self.recordButton setIsAccessibilityElement:YES];
[self.recordButton setAccessibilityLabel: @"toggle recording start"];
[self.recordButton setImage: recordImage forState:UIControlStateNormal];
[self.recordButton addTarget: self action:@selector(processButton:) forControlEvents:UIControlEventTouchUpInside];
[tmp addSubview:recordButton];
最终
....
[self setView:tmp];
[tmp release];
当我将此视图推入堆栈时,我调用了UIAccessibilityPostNotification
(UIAccessibilityScreenChangedNotification
, nil);。
开启语音识别后,当该视图显示时,我可以滑动并使我的每个元素(UIButtonBarItem
、UILabel
和UIButton
)获得焦点,并且我可以通过双击来激活它们。然而,VoiceOver没有提供有关这些元素的任何信息。在辅助功能检查器中进行测试,显示了我通过aControl.accessibilityLabel = @"the label"设置的标签。
此视图用于记录音频。如果我激活按钮并记录音频,然后停止录制,现在VoiceOver会在我聚焦它们时朗读元素的标签?为什么VoiceOver在视图首次加载时不会讲述信息?任何线索都将不胜感激!
我正在iPad 2上测试iOS 4.3.3。