1. 如果初始化UIBarButtonItem的时候,customView为UIButton的话,为UIBarButtonItem或UIButton设置accessibilityLabel均可;如果加了一层UIView做为UIButton的containerView,然后把这个containerView设置为UIBarButtonItem的customView,这个时候则只能对UIButton设置accessibilityLabel
案例:返回按钮的修改;其他页面rightbarbuttonitem的修改
2. 对于UITableViewCell,直接通过设置cell的accessibilityLabel属性来实现即可,可以将各个控件的accessibilityLabel组装成一行更加移动简单的文字返回。Apple官方的示例代码或者在自定义UITableViewCell的时候覆盖accessibilityLabel即可:
@implementation WeatherTableViewController
// This is a view that provides weather information. It contains a city subview and a temperature subview, each of which provides a separate label.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
// set up the cell here...
NSString *cityLabel = [self.weatherCity accessibilityLabel];
NSString *temperatureLabel = [self.weatherTemp accessibilityLabel];
// Combine the city and temperature information so that VoiceOver users can get the weather information with one gesture.
[cell setAccessibilityLabel:[NSString stringWithFormat:@"%@, %@", cityLabel, temperatureLabel]];
return cell;
}
@end
参考资料: