I have a UITableViewController and I'm trying to customize the section headers to look more like plain text. I find that when I add a subview to a custom header (described in detail below), it disrupts the navigation of the VoiceOver headers.
For example: Let's say I have a table with three headers: Header1, Header2, Header3.
Without a custom implementation of the viewForHeaderInSection method, I can switch the voice transmission rotor to navigate the headers, and everything works as intended.
When I implement the viewForHeaderInSection method as follows, I can move from Header1 to Header2 to Header3 and back to Header2, but then the scoring loses all the headers (saying “no headers found”).
I found that the problem starts when I add the Label header as a subview to the headerView. I tried setting headerLabel to a hidden accessibility element, so the voice acting will not pick it up, but the problem will not go away.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableView.frame.size.width,30)]; UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, headerView.frame.size.width-120.0, headerView.frame.size.height)]; headerLabel.textAlignment = UITextAlignmentLeft; headerLabel.font = [UIFont boldSystemFontOfSize:22]; headerLabel.text = [headersArray objectAtIndex:section]; headerLabel.backgroundColor = [UIColor clearColor]; [headerView addSubview:headerLabel]; return headerView; }
Any ideas that VoiceOver reacts to will be appreciated.
Thanks.
source share