解决:
我按照了更新中的链接,现在UITableViewCell的按钮适用于VoiceOver。
情况:
我正在为应用实施VoiceOver辅助功能。 我有一个自定义UITableViewCell(下面的代码),可以通过用户单击单元格在展开和正常视觉(选定与未选中)之间切换。扩展所涉及的一切都按照我的设计进行。 在自定义UITableViewCell中,我有一个UILabel和2个UIButtons。 UILabel被VoiceOver辅助功能识别,但忽略了UIButtons。
问题:
我需要VoiceOver辅助功能才能识别UIButtons并阅读其辅助功能标签和/或提示。
守则:
-(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];
}
更新:
看起来所描述的内容here是可行的方法。