UITextView中设置的语音选择/逐段阅读(UITextView setup for Voice

2019-10-17 12:27发布

我有一个UITextView设置了,我试图做访问的更新日志。 我想有这样也好,启用语音和整个段落的选择和阅读。

目前我可以设置accessibilityTrait和具有在一个巨大的块朗读整个视图,或不设置accessibilityTrait设置并具有一次只选择一行。 有没有办法来阻止段落在一起的VoiceOver?

这是我目前使用的代码:

NSString *string = someMultiparagraphString;
NSLog(@"Log is: %@", string);

CGFloat height = [string sizeWithFont:normalFont 
                    constrainedToSize:CGSizeMake(280.0f, CGFLOAT_MAX) 
                        lineBreakMode:UILineBreakModeTailTruncation].height;

CGRect logRect = CGRectMake(10.0f, 10.0f, rect.size.width - 40.0f, height);

UITextView *logView = [[UITextView alloc] initWithFrame:logRect];
logView.font = normalFont;
logView.text = string;
logView.editable = NO;
//logView.accessibilityTraits = UIAccessibilityTraitUpdatesFrequently;
[self addSubview:logView];
[logView release];
文章来源: UITextView setup for Voice Over to select/read by paragraph