ios - 为 UITableView 标题文本设置 accessibilityLabel
问题描述
我正在尝试找到一种方法来设置accessibilityLabel
我的 tableview 的标题文本。
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"Table View Header";
}
就我而言,我的可访问性标签与返回的 tableview 的标题文本不同。
解决方案
或者,您也可以使用 的textLabel
属性UITableViewHeaderFooterView
。
代码示例:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UITableViewHeaderFooterView *headerView = [[UITableViewHeaderFooterView alloc] init];
headerView.textLabel.text = @"tableview header";
headerView.isAccessibilityElement = YES;
headerView.accessibilityLabel = @"tableview header for accessibility";
return headerView;
}
推荐阅读
- r - 如何防止 JS 代码在 R Shiny 中多次运行?
- google-bigquery - 将数据集添加为另一个数据集的读取器
- c# - 执行此代码的更好方法。从字符串、Math.Round 转换并处理负数
- python - 在 Python 中,我需要在文本文件中搜索一个数字并将下一个单词 avec 逗号
- html - 使用 height: auto 拉伸图像。这个有什么替代品?
- json - 如何修复 JSON 中的意外字符串
- prestashop - {convertPrice price=$product.price} 在 prestashop 1.7 中不起作用
- python - 不能让我的脚本使用参数生成特定的 url
- python-unittest - 使用 unittest 配置 Allure
- sql-server - SQL Data Sync with Azure do not show my database