Skip to content

Commit 271c59b

Browse files
committed
Fixed presentation of PFAlertView when rootViewController has presentedViewController.
1 parent f5d1279 commit 271c59b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Parse/Internal/PFAlertView.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ + (void)showAlertWithTitle:(NSString *)title
5252

5353
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
5454
UIViewController *viewController = keyWindow.rootViewController;
55+
while (viewController.presentedViewController) {
56+
viewController = viewController.presentedViewController;
57+
}
5558

5659
[viewController presentViewController:alertController animated:YES completion:nil];
5760
} else {

Tests/Unit/AlertViewTests.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ - (void)testShowAlertWithAlertViewController {
4444
id mockedApplication = PFStrictClassMock([UIApplication class]);
4545
UIWindow *mockedWindow = PFStrictClassMock([UIWindow class]);
4646
UIViewController *mockedViewController = PFStrictClassMock([UIViewController class]);
47+
OCMStub(mockedViewController.presentedViewController).andReturn(nil);
4748

4849
// Using .andReturn() here will result in a retain cycle, which will cause our mocked shared application to
4950
// persist across tests.

0 commit comments

Comments
 (0)