From 66a2f708a9522712861b842fd7486db4c4f3415d Mon Sep 17 00:00:00 2001 From: AUiBrian Date: Wed, 7 Sep 2011 04:32:09 -0400 Subject: [PATCH] added back in old non block based animations for targets before ios4.0 --- class/HPGrowingTextView.m | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/class/HPGrowingTextView.m b/class/HPGrowingTextView.m index b727444..7537120 100644 --- a/class/HPGrowingTextView.m +++ b/class/HPGrowingTextView.m @@ -214,18 +214,30 @@ - (void)textViewDidChange:(UITextView *)textView { if(animateHeightChange) { - [UIView animateWithDuration:0.1f - delay:0 - options:(UIViewAnimationOptionAllowUserInteraction| - UIViewAnimationOptionBeginFromCurrentState) - animations:^(void) { - [self resizeTextView:newSizeH]; - } - completion:^(BOOL finished) { - if ([delegate respondsToSelector:@selector(growingTextView:didChangeHeight:)]) { - [delegate growingTextView:self didChangeHeight:newSizeH]; - } - }]; + if ([UIView resolveClassMethod:@selector(animateWithDuration:animations:)]) { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000 + [UIView animateWithDuration:0.1f + delay:0 + options:(UIViewAnimationOptionAllowUserInteraction| + UIViewAnimationOptionBeginFromCurrentState) + animations:^(void) { + [self resizeTextView:newSizeH]; + } + completion:^(BOOL finished) { + if ([delegate respondsToSelector:@selector(growingTextView:didChangeHeight:)]) { + [delegate growingTextView:self didChangeHeight:newSizeH]; + } + }]; +#endif + } else { + [UIView beginAnimations:@"" context:nil]; + [UIView setAnimationDuration:0.1f]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(growDidStop)]; + [UIView setAnimationBeginsFromCurrentState:YES]; + [self resizeTextView:newSizeH]; + [UIView commitAnimations]; + } } else { [self resizeTextView:newSizeH]; // [fixed] The growingTextView:didChangeHeight: delegate method was not called at all when not animating height changes.