VoiceOver在UITextView的两侧查找“清空行”

问题描述 投票:6回答:1

我有一个表视图,其中每个单元格只包含一个UITextView,设置如下:

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
// Declare and set text & frame
...
UITextView *textView = [[UITextView alloc] initWithFrame:frame];
textView.backgroundColor = [UIColor clearColor];
textView.editable = NO;
textView.font = font;
textView.scrollEnabled = NO;
textView.text = text;
[cell.contentView addSubview:textView];

当我使用VoiceOver进行测试时,我可以在文本视图中文本的左右边缘找到两个只是小空项目的地方,VoiceOver在其中显示“空行”。如果我有一个多行字符串,例如@"multiple\nlines",然后在第一行的右边缘有一个“空行”,在第二行的左边缘有另一行。我找不到第一行左边或第二行右边的“空行”,但据我所知,他们很难找到。

为什么VoiceOver会找到这些“空行”?我怎么摆脱他们?

ios uitextview voiceover
1个回答
0
投票

这是我们今天提出的this bug的解决方法。

子类UITextView和覆盖:

- (BOOL)isAccessibilityElement {
    return NO;
}

返回NO选择退出VoiceOver。然后,使容器向其添加textview并在容器视图上设置自定义accessibilityLabel:

containerView.accessibilityLabel = textview.text

这显然不适用于某些情况(我没有深入研究),但它至少会让你到一个文本视图不显示相关行为的地方。

© www.soinside.com 2019 - 2024. All rights reserved.