mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 11:17:04 +08:00
fix(ios): prevent layout in viewSafeAreaInsetsDidChange until first viewDidLayoutSubviews (#10151)
This commit is contained in:
@ -74,6 +74,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
|
||||
public isBackstackSkipped: boolean;
|
||||
public isBackstackCleared: boolean;
|
||||
private didFirstLayout: boolean;
|
||||
// this is initialized in initWithOwner since the constructor doesn't run on native classes
|
||||
private _isRunningLayout: number;
|
||||
private get isRunningLayout() {
|
||||
@ -84,6 +85,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
}
|
||||
private finishRunningLayout() {
|
||||
this._isRunningLayout--;
|
||||
this.didFirstLayout = true;
|
||||
}
|
||||
private runLayout(cb: () => void) {
|
||||
try {
|
||||
@ -98,6 +100,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
const controller = <UIViewControllerImpl>UIViewControllerImpl.new();
|
||||
controller._owner = owner;
|
||||
controller._isRunningLayout = 0;
|
||||
controller.didFirstLayout = false;
|
||||
|
||||
return controller;
|
||||
}
|
||||
@ -125,7 +128,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
const isBack = isBackNavigationTo(owner, newEntry);
|
||||
owner.onNavigatingTo(newEntry.entry.context, isBack, newEntry.entry.bindingContext);
|
||||
}
|
||||
|
||||
|
||||
if (frame) {
|
||||
if (!owner.parent) {
|
||||
owner._frame = frame;
|
||||
@ -276,7 +279,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
|
||||
public viewSafeAreaInsetsDidChange(): void {
|
||||
super.viewSafeAreaInsetsDidChange();
|
||||
if (this.isRunningLayout) {
|
||||
if (this.isRunningLayout || !this.didFirstLayout) {
|
||||
return;
|
||||
}
|
||||
const owner = this._owner?.deref();
|
||||
|
Reference in New Issue
Block a user