I am programming the creation of the UINavigationContoller for iOS, and I am having problems that make it fully accessible. In loadView I create the main UIView and set it as UNAVAILABLE:
- (void)loadView { CGRect viewRect = [[UIScreen mainScreen] applicationFrame]; UIView *tmp = [[UIView alloc] initWithFrame:viewRect]; [tmp setIsAccessibilityElement:NO];
Then I add additional UIViews that contain only background images, and also set them as inaccessible. All views and controls are added to the "tmp" UIView created above. Here is an example of a background:
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];
Finally, I add UIButton , UILabel and UIButtonBarItem . I add these latter so that they are at the top of the view hierarchy. I add labels and accessibility features for them. Here is the 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];
finally
.... [self setView:tmp]; [tmp release];
I called UIAccessibilityPostNotification ( UIAccessibilityScreenChangedNotification , nil); when I push this view onto the stack.
When the audio mode is on, when the view is displayed, I can swipe and give each of my elements (focus UIButtonBarItem , UILabel and UIButton ), and I can activate them by double-clicking. However, VoiceOver does not contain item information. Testing in the simulator with the accessibility inspector shows the labels that I set through aControl.accessibilityLabel = @ "label";
This view is used to record sound. If I activate the buttons and record sound and stop recording, will VoiceOver now speak labels for elements when I focus them? Why doesn't VoiceOver talk about when information is first downloaded? Any hints appreciated!
I am testing iPad 2 with iOS 4.3.3.