mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix(core): guard unstable page/frame init contexts under async conditions (#9428)
This commit is contained in:
@ -353,6 +353,9 @@ export class ActionBar extends ActionBarBase {
|
||||
}
|
||||
|
||||
private setColor(navBar: UINavigationBar, color?: Color) {
|
||||
if (!navBar) {
|
||||
return;
|
||||
}
|
||||
if (color) {
|
||||
navBar.titleTextAttributes = <any>{
|
||||
[NSForegroundColorAttributeName]: color.ios,
|
||||
@ -443,13 +446,12 @@ export class ActionBar extends ActionBarBase {
|
||||
}
|
||||
|
||||
private get navBar(): UINavigationBar {
|
||||
const page = this.page;
|
||||
// Page should be attached to frame to update the action bar.
|
||||
if (!page || !page.frame) {
|
||||
if (this.page?.frame?.ios?.controller) {
|
||||
return (<UINavigationController>this.page.frame.ios.controller).navigationBar;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return (<UINavigationController>page.frame.ios.controller).navigationBar;
|
||||
}
|
||||
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
|
@ -224,7 +224,7 @@ export class Frame extends FrameBase {
|
||||
this._ios._disableNavBarAnimation = disableNavBarAnimationCache;
|
||||
}
|
||||
|
||||
if (this._ios.controller.navigationBar) {
|
||||
if (this._ios.controller?.navigationBar) {
|
||||
this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty();
|
||||
}
|
||||
|
||||
@ -666,7 +666,9 @@ class iOSFrame implements iOSFrameDefinition {
|
||||
}
|
||||
public set showNavigationBar(value: boolean) {
|
||||
this._showNavigationBar = value;
|
||||
this._controller.setNavigationBarHiddenAnimated(!value, !this._disableNavBarAnimation);
|
||||
if (this._controller) {
|
||||
this._controller.setNavigationBarHiddenAnimated(!value, !this._disableNavBarAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
public get navBarVisibility(): 'auto' | 'never' | 'always' {
|
||||
|
@ -177,7 +177,9 @@ class UIViewControllerImpl extends UIViewController {
|
||||
}
|
||||
|
||||
// If page was shown with custom animation - we need to set the navigationController.delegate to the animatedDelegate.
|
||||
frame.ios.controller.delegate = this[DELEGATE];
|
||||
if (frame.ios?.controller) {
|
||||
frame.ios.controller.delegate = this[DELEGATE];
|
||||
}
|
||||
|
||||
frame._processNavigationQueue(owner);
|
||||
|
||||
|
Reference in New Issue
Block a user