Comments (6)
import FlexLayout
import UIKit
class ViewController: UIViewController {
let container = UIView()
lazy var kindView: AKindView = {
let view = AKindView()
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "set", style: .plain, target: self, action: #selector(changeAction))
view.addSubview(container)
container.frame = view.bounds
container.flex.paddingTop(100).direction(.column).justifyContent(.center).alignItems(.stretch).define { flex in
flex.addItem(kindView)
}
kindView.setup("A")
container.flex.layout(mode: .adjustHeight)
}
@objc func changeAction() {
kindView.setup("B")
container.flex.layout(mode: .adjustHeight)
}
}
import FlexLayout
import UIKit
class AKindView: UIView {
lazy var btnA: UIButton = {
let btn = UIButton()
btn.setTitle("ABC", for: .normal)
btn.backgroundColor = .orange
return btn
}()
lazy var btnB: UIButton = {
let btn = UIButton()
btn.setTitle("DEF", for: .normal)
btn.backgroundColor = .orange
return btn
}()
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup(_ x: String) {
subviews.forEach { $0.removeFromSuperview() }
flex.padding(15).define { flex in
flex.addItem().width(100%).direction(.row).justifyContent(.spaceAround)
.define { flex in
for i in 1 ... 4 {
let label = UILabel()
label.text = "\(x)--\(i)"
flex.addItem(label).height(44).width(20%)
}
}
flex.addItem().height(60).marginTop(15).direction(.row).alignItems(.stretch).define { flex in
flex.addItem(btnA).grow(1).shrink(1)
flex.addItem().width(11)
flex.addItem(btnB).grow(1).shrink(1)
}
}
}
}
from flexlayout.
Same issue, has anyone fixed it yet?
from flexlayout.
The issue here is that when setup()
is called multiple times btnA
and btnB
wind up moving between different superviews. This means their corresponding node still has an associated parent when YGNodeInsertChild()
is called, triggering the assert.
It looks like we previously had modified YGLayout
to clean up these parent references (c303faa) but this was overwritten when we updated to Yoga 2.0. I have a PR (#242) to restore these lines and keep us from hitting the assert.
from flexlayout.
from flexlayout.
The fix will be merged today.
from flexlayout.
The fix has been released.
from flexlayout.
Related Issues (20)
- How to subview controller in flex layout ?
- why not update yoga and yogakit? HOT 2
- Why is the subview constraint incorrect? HOT 1
- Nice work! HOT 1
- UILabel will get out of superview's bounds when text is too long HOT 2
- error: 'YGEnums.h' file not found HOT 3
- 'grow' not take up rest of space of cotainer. HOT 3
- 'YGEnums.h' file not found Error HOT 4
- Pods/FlexLayout/Sources/yoga/Yoga-internal.h:9:10: 'algorithm' file not found HOT 5
- how to use inline-flex feature HOT 1
- Are there plans to support macos? HOT 1
- FlexLayout package does not build with SwiftPM HOT 1
- 'YGEnums.h' file not found - When adding FlexLayout as dependency of another Swift Package. HOT 8
- ABI stability swift evolution support for different swift versions
- Use of bitwise '|' with boolean operands HOT 4
- Swift Error causing debugger not working
- Crash occurs when a `.wrapReverse` flexbox container has a `.display(.none)` item.
- Flexbox gap of Yoga in FlexLayout? HOT 2
- Override UITableViewCell
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexlayout.