This other stack overflow question has the answer. Follow the tutorial in the answers.
UIButton in TableViewCell VoiceOver Accessibility
-
23-06-2022 - |
문제
SOLVED:
I followed the link in the update and now the UITableViewCell's buttons are working for VoiceOver.
The Situation:
I'm implementing VoiceOver accessibility for an app. I have a custom UITableViewCell (code below) that can toggle between an expanded and a normal visual (selected vs unselected) by the user clicking the cell. Everything involved with expansion works according to my design. In the custom UITableViewCell, I have a UILabel and 2 UIButtons. The UILabel is recognized by the VoiceOver accessibility feature, but the UIButtons are ignored.
The Problem:
I need the VoiceOver Accessibility feature to recognize the UIButtons and read their accessibility labels and/or hints.
The Code:
-(id) init{
...
_leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
_rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_leftButton.titleLabel setFont:[UIFont fontWithName:FONT size:12]];
[_rightButton.titleLabel setFont:[UIFont fontWithName:FONT size:12]];
[_leftButton addTarget:self action:@selector(clickButtonLeft:) forControlEvents:UIControlEventTouchUpInside];
[_rightButton addTarget:self action:@selector(clickButtonRight:) forControlEvents:UIControlEventTouchUpInside];
[_leftButton setFrame:CGRectMake(CELL_DETAILS_SIDE_PADDING,
CELL_PADDING + CELL_NORMAL_HEIGHT + CELL_EXPANDED_PADDING - CELL_BUTTON_HEIGHT-7,
70, CELL_BUTTON_HEIGHT)];
[_leftButton setImage:[UIImage imageNamed:@"giftIcon.png"] forState:UIControlStateNormal];
[_leftButton setTitle:@" Gift This" forState:UIControlStateNormal];
[_rightButton setFrame:CGRectMake(self.frame.size.width - 140 - CELL_DETAILS_SIDE_PADDING,
CELL_PADDING + CELL_NORMAL_HEIGHT + CELL_EXPANDED_PADDING - CELL_BUTTON_HEIGHT-7,
140, CELL_BUTTON_HEIGHT)];
[_rightButton setImage:[UIImage imageNamed:@"buyPack.png"] forState:UIControlStateNormal];
[_rightButton setTitle:@" Buy For Yourself" forState:UIControlStateNormal];
_description = [[UILabel alloc] initWithFrame:CGRectMake(CELL_DETAILS_SIDE_PADDING, CELL_PADDING+CELL_NORMAL_HEIGHT+10,
self.frame.size.width - 2*CELL_DETAILS_SIDE_PADDING, 50)];
_description.numberOfLines = 0;
[_description setLineBreakMode:NSLineBreakByWordWrapping];
[_description setFont:[UIFont fontWithName:FONT size:13]];
[_description setBackgroundColor:[UIColor clearColor]];
[_description setTextColor:[UIColor whiteColor]];
}
- (void) expandCell
{
...
[self addSubview:_description];
[self addSubview:_leftButton];
[self addSubview:_rightButton];
}
UPDATE:
It looks like what is described here is the way to go.
해결책