Skip to content
Browse files

Improved reliability to BlockTextpromptAlertView

When calling show to BlockTextpromptAlertView in some cases and
devices, the AlertView didn't go up and stood behind the keyboard. So
instead of using an NSTimer to trigger to the TextField
becomeFirstResponder, now it's done via NSNotificationCenter from the
animations completion block from the superclass BlockAlertView.
  • Loading branch information...
1 parent 4999c4a commit c3797b77a8e4d4712bff9f3d882efab2ae8e1621 @natanrolnik natanrolnik committed May 20, 2012
View
4 BlockAlertsDemo/ToAddToYourProjects/BlockAlertView.m
@@ -285,7 +285,9 @@ - (void)show
center.y -= kAlertViewBounce;
_view.center = center;
}
- completion:nil];
+ completion:^(BOOL finished) {
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"AlertViewFinishedAnimations" object:nil];
+ }];
}];
[self retain];
View
3 BlockAlertsDemo/ToAddToYourProjects/BlockTextPromptAlertView.m
@@ -83,12 +83,13 @@ - (void)show {
[super show];
- [self.textField performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.5];
+ [[NSNotificationCenter defaultCenter] addObserver:textField selector:@selector(becomeFirstResponder) name:@"AlertViewFinishedAnimations" object:nil];
}
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated {
[super dismissWithClickedButtonIndex:buttonIndex animated:animated];
+ [[NSNotificationCenter defaultCenter] removeObserver:textField];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
}

0 comments on commit c3797b7

Please sign in to comment.
Something went wrong with that request. Please try again.