CYRTextView
CYRTextView copied to clipboard
Support storyboards with initWithCoder:
Hello,
Cool view! You should add support for storyboards by implementing initWithCoder:
Thanks, Leo
Hi Leo,
Thanks for the feature suggestion! I took a stab at this but ran into some issues since the text storage is already created when calling [super initWithCoder:]. I've posted my attempt below. Suggestions or pull requests welcome!
- Illya
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
CYRTextStorage *textStorage = [CYRTextStorage new];
CYRLayoutManager *layoutManager = [CYRLayoutManager new];
self.lineNumberLayoutManager = layoutManager;
// Wrap text to the text view's frame
self.textContainer.widthTracksTextView = YES;
[layoutManager addTextContainer:self.textContainer];
[textStorage removeLayoutManager:textStorage.layoutManagers.firstObject];
[textStorage addLayoutManager:layoutManager];
self.syntaxTextStorage = textStorage;
self.contentMode = UIViewContentModeRedraw; // causes drawRect: to be called on frame resizing and device rotation
[self _commonSetup];
}
return self;
}