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

How to update flex layout after first assign ? #135

Open
Villy21 opened this issue Jul 18, 2019 · 1 comment
Open

How to update flex layout after first assign ? #135

Villy21 opened this issue Jul 18, 2019 · 1 comment

Comments

@Villy21
Copy link

@Villy21 Villy21 commented Jul 18, 2019

Hello,
I made some layout like this

   holderView.flex.direction(.column).define { (flex) in
        flex.addItem(imageView).aspectRatio(2.0/3.0)
        
        flex.addItem().marginTop(6).direction(.row).alignItems(.center).define { (flex) in
            flex.addItem(bookmark).width(7).height(11).marginRight(3)
            flex.addItem(titleLabel).grow(1)
        }
    }

And after some time I want to update layout and for example remove something

   holderView.flex.direction(.column).define { (flex) in
        flex.addItem(imageView).aspectRatio(2.0/3.0)
    }

But in this case removed view (bookmark, titleLabel) did not disappear from layout but they continue to layout in flex at the top of holderView.

Is this a bug/feature or I do something wrong ?

The only solution I found is

       holderView.removeAllSubviews()
       holderView.flex.direction .......

More interesting happened if I call initial layout several times. In this case UIView created by flex.addItem(). duplicate again and again. Old instances become empty but continue to layout in flex.

@iWECon
Copy link

@iWECon iWECon commented Dec 1, 2020

holderView.aspectRatio(nil).markDirty()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants