Finally I resolved it using UIAccessibilityContainer protocol and using my existing view hierarchy: A (parent), B (child) and C (child). I used another view, say X which was parent of A and implemented a UIAccessibilityContainer protocol in it. Here is example code of creation an array of UIAccessibilityElements which was created in view X.
- (NSArray *)voiceOverElements {
if (!_voiceOverElements) {
UIAccessibilityElement *element = [[UIAccessibilityElement alloc] initWithAccessibilityContainer:self];
CGRect frame = UIAccessibilityConvertFrameToScreenCoordinates(A.frame, self);
element.accessibilityFrame = frame;
_voiceOverElements = @[element];
for (UIView *view in A.subviews) {
UIAccessibilityElement * element = [[UIAccessibilityElement alloc] initWithAccessibilityContainer:self];
CGRect frame = UIAccessibilityConvertFrameToScreenCoordinates(view.frame, A);
element.accessibilityFrame = frame;
_voiceOverElements = [_voiceOverElements arrayByAddingObject:element];
}
}
return _voiceOverElements;
}
In the same view (X), UIAccessibilityContainer protocol was implemented as follows:
- (BOOL)isAccessibilityElement {
return NO;
}
- (id)accessibilityElementAtIndex:(NSInteger)index {
return [self.voiceOverElements objectAtIndex:index];
}
- (NSInteger)accessibilityElementCount {
return self.voiceOverElements.count;
}
- (NSInteger)indexOfAccessibilityElement:(id)element {
return [self.voiceOverElements indexOfObject:element];
}