Skip to content

Commit fa53012

Browse files
committed
Merge pull request #80 from ParsePlatform/nlutsenko.alertView
Fixed presentation of PFAlertView when rootViewController has presentedViewController.
2 parents 8523a75 + 271c59b commit fa53012

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
@@ -56,6 +56,9 @@ + (void)showAlertWithTitle:(NSString *)title
5656

5757
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
5858
UIViewController *viewController = keyWindow.rootViewController;
59+
while (viewController.presentedViewController) {
60+
viewController = viewController.presentedViewController;
61+
}
5962

6063
[viewController presentViewController:alertController animated:YES completion:nil];
6164
} 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)