Permalink
Browse files

[TIMOB-8373] fix auto height for text area; add border thickness to c…

…ontrol size calculations
  • Loading branch information...
1 parent 2bac83d commit fc9aa9eab2936fa6edd596e39e26251f504c424d @mstepanov committed Apr 5, 2012
Showing with 6 additions and 8 deletions.
  1. +6 −5 iphone/Classes/TiUITextArea.m
  2. +0 −3 iphone/Classes/TiUITextField.m
@@ -164,22 +164,23 @@ -(CGFloat)contentWidthForWidth:(CGFloat)value
if (value - txtWidth >= TXT_OFFSET) {
return (txtWidth + TXT_OFFSET);
}
- return txtWidth;
+ return txtWidth + 2 * self.layer.borderWidth;
}
-(CGFloat)contentHeightForWidth:(CGFloat)value
{
- if (![self hasText]) {
- return 0.0;
- }
CGFloat constrainedWidth = value - TXT_OFFSET;
if (constrainedWidth < 0) {
constrainedWidth = 0;
}
UITextView* ourView = (UITextView*)[self textWidgetView];
NSString* txt = ourView.text;
+ if (txt.length == 0) {
+ txt = @" ";
+ }
//sizeThatFits does not seem to work properly
- return [txt sizeWithFont:ourView.font constrainedToSize:CGSizeMake(constrainedWidth, 1E100) lineBreakMode:UILineBreakModeWordWrap].height;
+ CGFloat txtHeight = [txt sizeWithFont:ourView.font constrainedToSize:CGSizeMake(constrainedWidth, 1E100) lineBreakMode:UILineBreakModeWordWrap].height;
+ return txtHeight + 2 * self.layer.borderWidth;
}
- (void)scrollViewDidScroll:(id)scrollView
@@ -532,9 +532,6 @@ -(CGFloat)contentWidthForWidth:(CGFloat)value
-(CGFloat)contentHeightForWidth:(CGFloat)value
{
- if (![self hasText]) {
- return 0.0;
- }
return [[self textWidgetView] sizeThatFits:CGSizeMake(value, 0)].height;
}

0 comments on commit fc9aa9e

Please sign in to comment.