yoga: YogaKit does not correctly account for composite UIView when doing layout
I’ve been trying to render an instance of MKMapView
but failed to do so.
Here is a code that works without using Yoga
import UIKit
import MapKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let m = MKMapView()
m.frame.size = CGSize(width: self.view.frame.size.width, height: 100)
self.view.addSubview(m)
}
}
which renders the following view
but when I try to render a same map view using Yoga with the following code
import UIKit
import MapKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let m = MKMapView()
self.view.yg_usesYoga = true
self.view.yg_setWidth(self.view.bounds.size.width)
self.view.yg_setHeight(self.view.bounds.size.height)
m.yg_usesYoga = true
m.yg_setWidth(self.view.bounds.size.width)
m.yg_setHeight(100)
self.view.addSubview(m)
self.view.yg_applyLayout()
}
}
I get this
Which is basically a “white” map
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (8 by maintainers)
Commits related to this issue
- Add yg_isLeaf readonly property. This property is necessary to determine if YGNodeSetMeasureFunc needs to be called on YGAttachNodesFromViewHierachy. This property must return YES for all views that... — committed to guidomb/yoga by deleted user 8 years ago
- Add yg_isLeaf readonly property. This property is necessary to determine if YGNodeSetMeasureFunc needs to be called on YGAttachNodesFromViewHierachy. This property must return YES for all views that... — committed to guidomb/yoga by deleted user 8 years ago
The fix for this landed in 835bb1c. I’m going to close this, but feel free to open if something else arises!
@emilsjolander Oops! sorry didn’t see that. You were right it worked! Now the map renders correctly. I’ll prepare a PR. Thanks a lot helping me!