Fixes #606 #610
@@ -304,10 +304,14 @@ static YGSize YGMeasureView(
|
||||
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
|
||||
|
||||
|
||||
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
|
||||
![]() Instead of pointing to the issue. Can you comment in the code, why this check is added. Instead of pointing to the issue. Can you comment in the code, why this check is added.
![]() I think I think `!view.yoga.isUIView` this check is not required. Happy to hear about your inputs
![]() this condition practically says "we want to invoke this condition practically says "we want to invoke `sizeThatFits` only in case if the measured view is not a `UIView` instance or it's a `UIView`, but has got children". The check is needed because we do want to invoke `sizeThatFits` for a UILabel (for example) that has got no subviews, but returns a correct value as a result of invocation of `sizeThatFits`
![]() Done. Done.
![]() Aah Got it. Can you add a comment(in brief) explaining this before the condition? Aah Got it. Can you add a comment(in brief) explaining this before the condition?
![]() Done Done
|
||||
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
|
||||
.width = constrainedWidth,
|
||||
.height = constrainedHeight,
|
||||
}];
|
||||
CGSize sizeThatFits = CGSizeZero;
|
||||
|
||||
if ([view.subviews count] > 0) {
|
||||
sizeThatFits = [view sizeThatFits:(CGSize) {
|
||||
.width = constrainedWidth,
|
||||
.height = constrainedHeight,
|
||||
}];
|
||||
}
|
||||
|
||||
return (YGSize) {
|
||||
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
||||
|
Reference in New Issue
Block a user
why do we have to check it's a
UIView
or not?Because the other classes (like UILabel) return correct size for sizeThatFits if there are no subviews
I wonder if there is a cleaner way to do this...I don't want us to check the class of a view every time yoga measures it.
Do you have ideas by any chance? The problem is that it seems that it's only UIView that results in this "odd" behavior - returns current size when it's empty.
An option could be to create a flag
isUIView
inYGLayout
and initialize it ininitWithView:
. What would you say?I like it! Lets give it a shot.