UITextView setup for Voice Over to select/read by paragraph

我们两清 提交于 2019-12-14 02:32:18

问题


I have a UITextView set up with an updating log that I'm trying to make accessible. I'd like to have it so, with Voice Over enabled, and entire paragraph is selected and read.

Currently I can either set the accessibilityTrait and have the entire view read aloud in one giant block, or not set the accessibilityTrait set and have only a single line selected at a time. Is there a way to block paragraphs together for VoiceOver?

Here is the code I'm currently using:

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];

来源:https://stackoverflow.com/questions/13920012/uitextview-setup-for-voice-over-to-select-read-by-paragraph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!