Skip to content

Commit e61affc

Browse files
authored
Merge pull request NativeScript#2384 from NativeScript/issue-2173
Fix: iOS onSuspend + showModal() returning "Error: This value is not …
2 parents bc1224e + 8dc732c commit e61affc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tns-core-modules/ui/page/page.ios.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,20 @@ export class Page extends pageCommon.Page {
372372
this._ios.modalPresentationStyle = UIModalPresentationStyle.UIModalPresentationFormSheet;
373373
this._UIModalPresentationFormSheet = true;
374374
}
375-
375+
376376
super._raiseShowingModallyEvent();
377377

378378
parent.ios.presentViewControllerAnimatedCompletion(this._ios, utils.ios.MajorVersion >= 7, null);
379-
UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion.call(parent.ios.transitionCoordinator(), null, () => this._raiseShownModallyEvent());
379+
let transitionCoordinator = parent.ios.transitionCoordinator();
380+
if (transitionCoordinator){
381+
UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion.call(transitionCoordinator, null, () => this._raiseShownModallyEvent());
382+
}
383+
else {
384+
// Apparently iOS 9+ stops all transitions and animations upon application suspend and transitionCoordinator becomes null here in this case.
385+
// Since we are not waiting for any transition to complete, i.e. transitionCoordinator is null, we can directly raise our shownModally event.
386+
// Take a look at https://github.com/NativeScript/NativeScript/issues/2173 for more info and a sample project.
387+
this._raiseShownModallyEvent();
388+
}
380389
}
381390

382391
protected _hideNativeModalView(parent: Page) {

0 commit comments

Comments
 (0)