Turning off text view scrolling crashes layout manager
| Originator: | robnapier | ||
| Number: | rdar://14568899 | Date Originated: | 30-Jul-2013 09:29 AM |
| Status: | Duplicate/14571453 | Resolved: | 30-Jul-2013 09:29 AM |
| Product: | iOS SDK | Product Version: | |
| Classification: | Reproducible: |
Summary: If scrollEnabled is set to NO on a UITextView, and it is resized with autolayout, then giving it a custom NSLayoutManager will crash with the exception "*** -[NSLayoutManager glyphRangeForTextContainer:]: given container does not appear in the list of containers for this NSLayoutManager.'" Steps to Reproduce: UITextView *textView = [[UITextView alloc] initWithFrame:CGRectZero]; [textView setTranslatesAutoresizingMaskIntoConstraints:NO]; [self.view addSubview:textView]; NSDictionary *views = NSDictionaryOfVariableBindings( textView ); [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[textView]-|" options:0 metrics:nil views:views]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[textView]-|" options:0 metrics:nil views:views]]; textView.scrollEnabled = NO; self.textStorage = [[NSTextStorage alloc] initWithString:@"This is some stuff"]; self.layoutManager = [[NSLayoutManager alloc] init]; [self.textStorage addLayoutManager:self.layoutManager]; [self.layoutManager addTextContainer:textView.textContainer]; Expected Results: This should behave the same with or without the scrollEnabled=NO. Actual Results: Without scrollEnabled=NO, this works as expected (the text appears). With scrollEnabled=NO, this crashes as noted: '*** -[NSLayoutManager glyphRangeForTextContainer:]: given container does not appear in the list of containers for this NSLayoutManager.' Regression: Unknown. Notes: I've seen this crash using autosizing as well (without autolayout), but have had more trouble reproducing it as reliably. I believe the problem is actually just when the text view resizes rather than autolayout specifically. The same behavior occurs if a custom NSTextContainer is passed to the text view: self.textContainer = [[NSTextContainer alloc] initWithSize:self.view.bounds.size]; UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds textContainer:self.textContainer];
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!