Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic height view #14

Closed
Dan2552 opened this issue Sep 14, 2017 · 3 comments
Closed

Dynamic height view #14

Dan2552 opened this issue Sep 14, 2017 · 3 comments

Comments

@Dan2552
Copy link

Dan2552 commented Sep 14, 2017

Marklight looks great, fantastic work!

When using a plain UITextView, as I type the size of the view changes to fit the content/text of the view. When enabling Marklight, this behaviour seems to stop. Do you know what could be causing this?

Only constraints for the view in question are (using PureLayout):

view.autoPinEdge(.top, to: .bottom, of: previousView, withOffset: 8)
view.autoPinEdge(toSuperviewEdge: .left, withInset: 8)
view.autoPinEdge(toSuperviewEdge: .right, withInset: 8)
@macteo
Copy link
Owner

macteo commented Sep 14, 2017

Hello, could you link to a sample project with the two different behaviours?
Thanks

@Dan2552
Copy link
Author

Dan2552 commented Sep 17, 2017

Thanks for your time.

Here's a sample project:
https://www.dropbox.com/s/dj4y5s47f62n9m9/MarklightExample.zip?dl=1

@macteo
Copy link
Owner

macteo commented Sep 20, 2017

Hello,
the order is important, I've changed the sample project you provided with this code (taken from the provided Marklight Sample project) and the grow seems to work perfectly.

    private func insert(_ text: String) {
    let layoutManager = NSLayoutManager()
    
    let textStorage = MarklightTextStorage()
    // Assign the `UITextView`'s `NSLayoutManager` to the `NSTextStorage` subclass
    textStorage.addLayoutManager(layoutManager)
    
    let textContainer = NSTextContainer()
    layoutManager.addTextContainer(textContainer)
    
    let view = UITextView(frame: CGRect(x: 0, y: 0, width: 100, height: 20), textContainer: textContainer)
    
    // let view = UITextView()
    view.isScrollEnabled = false

    let last = scrollView.subviews.last!
    scrollView.addSubview(view)
    
    view.autoPinEdge(.top, to: .bottom, of: last, withOffset: 8)
    view.autoPinEdge(toSuperviewEdge: .left, withInset: 8)
    view.autoPinEdge(toSuperviewEdge: .right, withInset: 8)
}

simulator screen shot - iphone 8 - 2017-09-20 at 12 35 17

I'm closing the issue as it seems that it was caused by a wrong client-side implementation.

@macteo macteo closed this as completed Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants