解决了:
我按照更新中的链接进行操作,现在 UITableViewCell 的按钮可用于 VoiceOver。
情况:
我正在为应用程序实现 VoiceOver 辅助功能。我有一个自定义 UITableViewCell (下面的代码),可以通过用户单击单元格在展开和正常视觉(选择与未选择)之间切换。与扩展有关的一切都根据我的设计进行。在自定义 UITableViewCell 中,我有一个 UILabel 和 2 个 UIButton。VoiceOver 辅助功能可以识别 UILabel,但忽略 UIButton。
问题:
我需要 VoiceOver 辅助功能来识别 UIButton 并阅读它们的辅助功能标签和/或提示。
编码:
-(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];
}
更新:
看起来这里描述的是要走的路。