问题
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