I'm trying to add multiple exclusion paths to a series of UITextView
s laid out successively in a UIScrollView
, like so:
while (lastRenderedGlyph < self.manager.numberOfGlyphs) {
CGRect textViewFrame = CGRectMake(currentXOffset, 10,
width / 2,
height - 20);
CGSize columnSize = CGSizeMake(CGRectGetWidth(textViewFrame) - 20,
CGRectGetHeight(textViewFrame) - 10);
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:columnSize];
[self.manager addTextContainer:textContainer];
UITextView *textView = [[UITextView alloc] initWithFrame:textViewFrame
textContainer:textContainer];
textView.scrollEnabled = NO;
textView.editable = NO;
textView.dataDetectorTypes = UIDataDetectorTypeAll;
textView.delegate = self;
textView.selectable = YES;
UIImageView *goat = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"goat"]];
[goat setContentMode:UIViewContentModeScaleAspectFit];
goat.frame = CGRectMake(0.0, 0.0, 50.0, 50.0);
[textView addSubview:goat];
[self.scrollView addSubview:textView];
textView.textContainer.exclusionPaths = @[[UIBezierPath bezierPathWithRect:CGRectMake(0.0, 0.0, 50.0, 50.0)]];
currentXOffset += CGRectGetWidth(textViewFrame);
lastRenderedGlyph = NSMaxRange([self.manager glyphRangeForTextContainer:textContainer]);
}
However, this causes the app to freeze up, and I've traced the issue to the setting of the exclusion path on each NSTextContainer
. For example, if I set no exclusion paths, it works fine. Importantly, if I only set the exclusion path on the first NSTextContainer
, then everything works just fine - but anything above one, and the app freezes. What am I doing wrong, or is this a bug?