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.
Showing
1 changed file
with
8 additions
and
2 deletions
@@ -216,7 +216,10 @@ static const NSUInteger kDomainSection = 1; | @@ -216,7 +216,10 @@ static const NSUInteger kDomainSection = 1; | ||
216 | 216 | ||
217 | + (void)dismiss | 217 | + (void)dismiss |
218 | { | 218 | { |
219 | - [[sharedDialog parentViewController] dismissModalViewControllerAnimated:YES]; | 219 | + if ([sharedDialog respondsToSelector:@selector(presentingViewController)]) |
220 | + [[sharedDialog presentingViewController] dismissModalViewControllerAnimated:YES]; | ||
221 | + else | ||
222 | + [[sharedDialog parentViewController] dismissModalViewControllerAnimated:YES]; | ||
220 | } | 223 | } |
221 | 224 | ||
222 | - (void)viewDidDisappear:(BOOL)animated | 225 | - (void)viewDidDisappear:(BOOL)animated |
@@ -233,7 +236,10 @@ static const NSUInteger kDomainSection = 1; | @@ -233,7 +236,10 @@ static const NSUInteger kDomainSection = 1; | ||
233 | if (self == sharedDialog) { | 236 | if (self == sharedDialog) { |
234 | [[self class] dismiss]; | 237 | [[self class] dismiss]; |
235 | } else { | 238 | } else { |
236 | - [[self parentViewController] dismissModalViewControllerAnimated:YES]; | 239 | + if ([self respondsToSelector:@selector(presentingViewController)]) |
240 | + [[self presentingViewController] dismissModalViewControllerAnimated:YES]; | ||
241 | + else | ||
242 | + [[self parentViewController] dismissModalViewControllerAnimated:YES]; | ||
237 | } | 243 | } |
238 | } | 244 | } |
239 | 245 |
-
Please register or login to post a comment