Incorrect initial layout for multiple text containers
| Originator: | robnapier | ||
| Number: | rdar://14665078 | Date Originated: | 06-Aug-2013 05:50 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | |
| Classification: | Reproducible: |
Creating two non-scrollable UITextViews, each with its own text container, and laying out across them incorrectly manages the height. The final line of the first box is cut off. If the view is resized (auto-resize due to rotation for instance), then it correctly lays out.
Place some long piece of text in "sample.txt" and run the following. Note incorrect layout. Then rotate and note correct layout. Rotate back and note that layout continues to be correct.
- (void)viewDidLoad
{
[super viewDidLoad];
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
NSString *path = [[NSBundle mainBundle] pathForResource:@"sample.txt" ofType:nil];
NSString *string = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithString:string];
[textStorage addLayoutManager:layoutManager];
NSTextContainer *textContainer1 = [[NSTextContainer alloc] initWithSize:CGSizeMake(300, 100)];
[layoutManager addTextContainer:textContainer1];
UITextView *textView1 = [[UITextView alloc] initWithFrame:CGRectMake(300, 100, 300, 100) textContainer:textContainer1];
textView1.autoresizingMask = UIViewAutoresizingFlexibleWidth;
textView1.scrollEnabled = NO;
textView1.backgroundColor = [UIColor redColor];
[self.view addSubview:textView1];
NSTextContainer *textContainer2 = [[NSTextContainer alloc] initWithSize:CGSizeMake(300, 100)];
[layoutManager addTextContainer:textContainer2];
UITextView *textView2 = [[UITextView alloc] initWithFrame:CGRectMake(300, 300, 300, 100) textContainer:textContainer2];
textView1.scrollEnabled = NO;
textView2.backgroundColor = [UIColor greenColor];
[self.view addSubview:textView2];
}
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!