Skip to content

Commit

Permalink
Merge pull request #2338 from mstepanov/timob-8941
Browse files Browse the repository at this point in the history
[TIMOB-8941] iOS: Children views inside scrollview aren't calculating size properly
  • Loading branch information
vishalduggal committed Jun 13, 2012
2 parents e23eddb + c70b46f commit 5029d2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions iphone/Classes/TiUILabel.m
Expand Up @@ -45,6 +45,11 @@ -(CGSize)sizeForFont:(CGFloat)suggestedWidth
CGSize maxSize = CGSizeMake(suggestedWidth<=0 ? 480 : suggestedWidth, 1000);
CGSize shadowOffset = [label shadowOffset];
requiresLayout = YES;
if ((suggestedWidth > 0) && [value characterAtIndex:value.length-1] == ' ') {
// (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode method truncates
// the string having trailing spaces when given size parameter width is equal to the expected return width, so we adjust it here.
maxSize.width += 0.00001;
}
CGSize size = [value sizeWithFont:font constrainedToSize:maxSize lineBreakMode:UILineBreakModeTailTruncation];
if (shadowOffset.width > 0)
{
Expand Down
9 changes: 6 additions & 3 deletions iphone/Classes/TiUIScrollViewProxy.m
Expand Up @@ -199,7 +199,8 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
}
else if (TiDimensionIsAutoSize(constraint))
{
bounds.size.width = [child autoWidthForSize:CGSizeMake(boundingValue,bounds.size.height - offset2)] + offset;
// allow child to take as much horizontal space as scroll view width
bounds.size.width = [child autoWidthForSize:CGSizeMake(bounds.size.width,bounds.size.height - offset2)] + offset;
horizontalLayoutBoundary += bounds.size.width;
}
else if (TiDimensionIsAuto(constraint) )
Expand All @@ -211,7 +212,8 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
}
else {
//SIZE behavior
bounds.size.width = [child autoWidthForSize:CGSizeMake(boundingValue,bounds.size.height - offset2)] + offset;
// allow child to take as much horizontal space as scroll view width
bounds.size.width = [child autoWidthForSize:CGSizeMake(bounds.size.width,bounds.size.height - offset2)] + offset;
horizontalLayoutBoundary += bounds.size.width;
}
}
Expand All @@ -238,7 +240,8 @@ -(CGRect)computeChildSandbox:(TiViewProxy*)child withBounds:(CGRect)bounds
}
else {
//SIZE behavior
bounds.size.width = [child autoWidthForSize:CGSizeMake(boundingValue,bounds.size.height - offset2)] + offset;
// allow child to take as much horizontal space as scroll view width
bounds.size.width = [child autoWidthForSize:CGSizeMake(bounds.size.width,bounds.size.height - offset2)] + offset;
horizontalLayoutBoundary += bounds.size.width;
}
}
Expand Down

0 comments on commit 5029d2a

Please sign in to comment.