Permalink
Browse files

Fixed bug preventing ASIAuthenticationDialog from being dismissed

In iOS 5, the ASIAuthenticationDialog could not be dismissed using either the Cancel button or automatically by successfully logging in.
The bug is due to a change in UIViewController in iOS 5.  The class & instance "dismiss" methods are using [UIViewController parentViewController] which, as of iOS 5, no longer returns the presenting view controller.  A new property called 'presentingViewController' was added in iOS 5 to make up for this.

Changed the class & instance dismiss methods to use the "presentingViewController" property if it is available (iOS 5+).  If not, it falls back to the "parentViewController" property.
  • Loading branch information...
1 parent 4282568 commit ba67fc8ec9fd6acf9edeb5ae39a6539efe329613 @gcox gcox committed Dec 1, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 Classes/ASIAuthenticationDialog.m
@@ -216,7 +216,10 @@ - (UITextField *)domainField
+ (void)dismiss
{
- [[sharedDialog parentViewController] dismissModalViewControllerAnimated:YES];
+ if ([sharedDialog respondsToSelector:@selector(presentingViewController)])
+ [[sharedDialog presentingViewController] dismissModalViewControllerAnimated:YES];
+ else
+ [[sharedDialog parentViewController] dismissModalViewControllerAnimated:YES];
}
- (void)viewDidDisappear:(BOOL)animated
@@ -233,7 +236,10 @@ - (void)dismiss
if (self == sharedDialog) {
[[self class] dismiss];
} else {
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
+ if ([self respondsToSelector:@selector(presentingViewController)])
+ [[self presentingViewController] dismissModalViewControllerAnimated:YES];
+ else
+ [[self parentViewController] dismissModalViewControllerAnimated:YES];
}
}

0 comments on commit ba67fc8

Please sign in to comment.