mirror of
https://github.com/zhigang1992/MessagesTableViewController.git
synced 2026-01-12 22:48:53 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user