Skip to content

Commit

Permalink
added back in old non block based animations for targets before ios4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AUiBrian committed Sep 7, 2011
1 parent 0328bce commit 66a2f70
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions class/HPGrowingTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 66a2f70

Please sign in to comment.