-
Notifications
You must be signed in to change notification settings - Fork 229
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
Child already has a owner, it must be removed first. #237
Comments
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)
}
}
}
} |
Same issue, has anyone fixed it yet? |
The issue here is that when It looks like we previously had modified |
这是来自QQ邮箱的自动回复邮件。您好,已收到您的邮件。谢谢!
|
The fix will be merged today. |
The fix has been released. |
call setup method twice and then crash.
[email protected]
function YGAttachNodesFromViewHierachy(UIView *const view)
[email protected]
function YGAttachNodesFromViewHierachy(UIView *const view)
so, why remove these code
The text was updated successfully, but these errors were encountered: