Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-18139] Redisplay the alert controller #6453

Merged
merged 1 commit into from
Dec 8, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 27 additions & 6 deletions iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -852,16 +852,20 @@ -(void)didCloseWindow:(id<TiWindowProtocol>)theWindow

-(void)showControllerModal:(UIViewController*)theController animated:(BOOL)animated
{
BOOL trulyAnimated = animated;
UIViewController* topVC = [self topPresentedController];
if ([topVC isKindOfClass:[TiErrorController class]]) {
DebugLog(@"[ERROR] ErrorController is up. ABORTING showing of modal controller");
return;
}
if ([TiUtils isIOS8OrGreater]) {
if ([topVC isKindOfClass:[UIAlertController class]] && ![theController isKindOfClass:[TiErrorController class]]) {
if ( ((UIAlertController*)topVC).preferredStyle == UIAlertControllerStyleAlert ) {
DebugLog(@"[ERROR] UIAlertController is up and showing an alert. ABORTING showing of modal controller");
return;
if ([topVC isKindOfClass:[UIAlertController class]]) {
if (((UIAlertController*)topVC).preferredStyle == UIAlertControllerStyleAlert ) {
trulyAnimated = NO;
if (![theController isKindOfClass:[TiErrorController class]]) {
DebugLog(@"[ERROR] UIAlertController is up and showing an alert. ABORTING showing of modal controller");
return;
}
}
}
}
Expand All @@ -874,7 +878,7 @@ -(void)showControllerModal:(UIViewController*)theController animated:(BOOL)anima
}
}
[self dismissKeyboard];
[topVC presentViewController:theController animated:animated completion:nil];
[topVC presentViewController:theController animated:trulyAnimated completion:nil];
}

-(void)hideControllerModal:(UIViewController*)theController animated:(BOOL)animated
Expand All @@ -883,8 +887,17 @@ -(void)hideControllerModal:(UIViewController*)theController animated:(BOOL)anima
if (topVC != theController) {
DebugLog(@"[WARN] Dismissing a view controller when it is not the top presented view controller. Will probably crash now.");
}
BOOL trulyAnimated = animated;
UIViewController* presenter = [theController presentingViewController];
[presenter dismissViewControllerAnimated:animated completion:^{

if ([TiUtils isIOS8OrGreater]) {
if ([presenter isKindOfClass:[UIAlertController class]]) {
if (((UIAlertController*)presenter).preferredStyle == UIAlertControllerStyleAlert ) {
trulyAnimated = NO;
}
}
}
[presenter dismissViewControllerAnimated:trulyAnimated completion:^{
if (presenter == self) {
[self didCloseWindow:nil];
} else {
Expand All @@ -895,6 +908,14 @@ -(void)hideControllerModal:(UIViewController*)theController animated:(BOOL)anima
if ([theProxy conformsToProtocol:@protocol(TiWindowProtocol)]) {
[(id<TiWindowProtocol>)theProxy gainFocus];
}
} else if ([TiUtils isIOS8OrGreater]){
//This code block will only execute when errorController is presented on top of an alert
if ([presenter isKindOfClass:[UIAlertController class]] && (((UIAlertController*)presenter).preferredStyle == UIAlertControllerStyleAlert)) {
UIViewController* alertPresenter = [presenter presentingViewController];
[alertPresenter dismissViewControllerAnimated:NO completion:^{
[alertPresenter presentViewController:presenter animated:NO completion:nil];
}];
}
}
}
}];
Expand Down