smoother animation for textview dynamic resizing. fixed hidden auto-correct bug (this time, for second line of text). closes #8 moar bettar.

This commit is contained in:
Jesse Squires
2013-03-18 01:54:36 -04:00
parent a96c829b4e
commit c96300f8a8
2 changed files with 8 additions and 4 deletions

View File

@@ -138,7 +138,9 @@
- (void)adjustTextViewHeightBy:(CGFloat)changeInHeight
{
CGRect prevFrame = self.textView.frame;
int numLines = [JSBubbleView numberOfLinesForMessage:self.textView.text];
int numLines = MAX([JSBubbleView numberOfLinesForMessage:self.textView.text],
[self.textView.text numberOfLines]);
self.textView.frame = CGRectMake(prevFrame.origin.x,
prevFrame.origin.y,
@@ -149,11 +151,13 @@
0.0f,
(numLines >= 6 ? 4.0f : 0.0f),
0.0f);
self.textView.scrollEnabled = (numLines >= 6);
}
+ (CGFloat)textViewLineHeight
{
return 29.0f; // for fontSize 15.0f
return 30.0f; // for fontSize 15.0f
}
+ (CGFloat)maxLines

View File

@@ -239,7 +239,7 @@
changeInHeight = (textViewContentHeight + changeInHeight >= maxHeight) ? 0.0f : changeInHeight;
if(!isShrinking) // hackish -- to prevent ugly UI glitch with dynamic sizing of textview
if(!isShrinking)
[self.inputView adjustTextViewHeightBy:changeInHeight];
if(changeInHeight != 0.0f) {
@@ -258,7 +258,7 @@
inputViewFrame.size.height + changeInHeight);
}
completion:^(BOOL finished) {
if(isShrinking) // hackish -- to prevent ugly UI glitch with dynamic sizing of textview
if(isShrinking)
[self.inputView adjustTextViewHeightBy:changeInHeight];
}];