Skip to content

Support storyboards with initWithCoder: #4

Open

Description

@LeoNatan

Hello,

Cool view! You should add support for storyboards by implementing initWithCoder:

Thanks,
Leo

Activity

  1. illyabusigin commented on Jan 19, 2014

    @illyabusigin
    Owner

    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;
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions