ojr*_*ore 8 iphone objective-c uitableview
不管我怎么努力,我不能让我的自定义的UITableViewCell从演技像它应该下UIAccessiblity默认规则.我不希望这个单元格像一个辅助功能容器(本身),所以按照本指南,我应该可以访问所有的子视图,对吧?!它说要使每个元素单独访问,并确保单元本身不可访问.
- (BOOL)isAccessibilityElement
{
return NO;
}
- (NSString *)accessibilityLabel
{
return nil;
}
- (NSInteger)accessibilityElementCount
{
return 0;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier //cells use this reusage stuff
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
{
[self setIsAccessibilityElement:NO];
sub1 = [[UILabel alloc] initWithFrame:CGRectMake(0,0,1,1)];
[sub1 setAccessibilityLanguage:@"es"];
[sub1 setIsAccessibilityElement:YES];
[sub1 setAccessibilityLabel:sub1.text]
sub2 = [[UILabel alloc] initWithFrame:CGRectMake(0,0,1,1)];
[sub2 setAccessibilityLanguage:@"es"];
[sub2 setIsAccessibilityElement:YES];
[sub2 setAccessibilityLabel:sub2.text]
Run Code Online (Sandbox Code Playgroud)
语音系统一次性读取整个单元格的内容,即使我试图阻止这种行为.我可以说
[sub2 setIsAccessibilityElement:NO];
Run Code Online (Sandbox Code Playgroud)
但这会使这个元素完全不可读.我想保持它的可读性,但不要将整个单元格视为容器(并假设为英语).在这方面似乎没有很多信息,所以至少我想记录它.
Jil*_*ouc 12
如果您有2个单独的元素(sub1和sub2),则可以覆盖UIAccessibilityContainer非正式协议的方法.
- (NSInteger)accessibilityElementCount {
return 2;
}
- (id)accessibilityElementAtIndex:(NSInteger)index {
if (index == 0) {
return sub1;
} else if (index == 1) {
return sub2;
}
return nil;
}
- (NSInteger)indexOfAccessibilityElement:(id)element {
if (element == sub1) {
return 0;
} else if (element == sub2) {
return 1;
}
return NSNotFound;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4291 次 |
| 最近记录: |