mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Fix iOS layout in modal pages.
This commit is contained in:
@ -150,6 +150,15 @@
|
|||||||
<TypeScriptCompile Include="apps\animations\model.ts" />
|
<TypeScriptCompile Include="apps\animations\model.ts" />
|
||||||
<TypeScriptCompile Include="apps\orientation-demo\main-page.ts" />
|
<TypeScriptCompile Include="apps\orientation-demo\main-page.ts" />
|
||||||
<TypeScriptCompile Include="apps\tests\navigation-tests.ts" />
|
<TypeScriptCompile Include="apps\tests\navigation-tests.ts" />
|
||||||
|
<TypeScriptCompile Include="apps\tests\pages\page21.ts">
|
||||||
|
<DependentUpon>page21.xml</DependentUpon>
|
||||||
|
</TypeScriptCompile>
|
||||||
|
<TypeScriptCompile Include="apps\tests\pages\page20.ts">
|
||||||
|
<DependentUpon>page20.xml</DependentUpon>
|
||||||
|
</TypeScriptCompile>
|
||||||
|
<TypeScriptCompile Include="apps\tests\pages\page19.ts">
|
||||||
|
<DependentUpon>page19.xml</DependentUpon>
|
||||||
|
</TypeScriptCompile>
|
||||||
<TypeScriptCompile Include="apps\tests\ui\animation\animation-tests.ts" />
|
<TypeScriptCompile Include="apps\tests\ui\animation\animation-tests.ts" />
|
||||||
<TypeScriptCompile Include="apps\tests\ui\search-bar\search-bar-tests-native.android.ts" />
|
<TypeScriptCompile Include="apps\tests\ui\search-bar\search-bar-tests-native.android.ts" />
|
||||||
<TypeScriptCompile Include="apps\tests\ui\search-bar\search-bar-tests-native.d.ts" />
|
<TypeScriptCompile Include="apps\tests\ui\search-bar\search-bar-tests-native.d.ts" />
|
||||||
@ -157,6 +166,15 @@
|
|||||||
<TypeScriptCompile Include="apps\tests\ui\repeaterItems-bindingToGestures.ts" />
|
<TypeScriptCompile Include="apps\tests\ui\repeaterItems-bindingToGestures.ts" />
|
||||||
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-base-page.ts" />
|
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-base-page.ts" />
|
||||||
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-page.ts" />
|
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-page.ts" />
|
||||||
|
<Content Include="apps\tests\pages\page21.xml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Content>
|
||||||
|
<Content Include="apps\tests\pages\page20.xml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Content>
|
||||||
|
<Content Include="apps\tests\pages\page19.xml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Content>
|
||||||
<Content Include="apps\ui-tests-app\app.css" />
|
<Content Include="apps\ui-tests-app\app.css" />
|
||||||
<TypeScriptCompile Include="apps\ui-tests-app\pages\handlers.ts" />
|
<TypeScriptCompile Include="apps\ui-tests-app\pages\handlers.ts" />
|
||||||
<TypeScriptCompile Include="apps\ui-tests-app\pages\htmlview.ts" />
|
<TypeScriptCompile Include="apps\ui-tests-app\pages\htmlview.ts" />
|
||||||
|
@ -21,7 +21,7 @@ class UIViewControllerImpl extends UIViewController {
|
|||||||
|
|
||||||
public didRotateFromInterfaceOrientation(fromInterfaceOrientation: number) {
|
public didRotateFromInterfaceOrientation(fromInterfaceOrientation: number) {
|
||||||
trace.write(this._owner + " didRotateFromInterfaceOrientation(" + fromInterfaceOrientation + ")", trace.categories.ViewHierarchy);
|
trace.write(this._owner + " didRotateFromInterfaceOrientation(" + fromInterfaceOrientation + ")", trace.categories.ViewHierarchy);
|
||||||
if ((<any>this._owner)._isModal) {
|
if (this._owner._isModal) {
|
||||||
var parentBounds = (<any>this._owner)._UIModalPresentationFormSheet ? (<UIView>this._owner._nativeView).superview.bounds : UIScreen.mainScreen().bounds;
|
var parentBounds = (<any>this._owner)._UIModalPresentationFormSheet ? (<UIView>this._owner._nativeView).superview.bounds : UIScreen.mainScreen().bounds;
|
||||||
utils.ios._layoutRootView(this._owner, parentBounds);
|
utils.ios._layoutRootView(this._owner, parentBounds);
|
||||||
}
|
}
|
||||||
@ -35,7 +35,13 @@ class UIViewControllerImpl extends UIViewController {
|
|||||||
|
|
||||||
public viewDidLayoutSubviews() {
|
public viewDidLayoutSubviews() {
|
||||||
trace.write(this._owner + " viewDidLayoutSubviews, isLoaded = " + this._owner.isLoaded, trace.categories.ViewHierarchy);
|
trace.write(this._owner + " viewDidLayoutSubviews, isLoaded = " + this._owner.isLoaded, trace.categories.ViewHierarchy);
|
||||||
this._owner._updateLayout();
|
if (this._owner._isModal) {
|
||||||
|
var parentBounds = (<any>this._owner)._UIModalPresentationFormSheet ? this._owner._nativeView.superview.bounds : UIScreen.mainScreen().bounds;
|
||||||
|
utils.ios._layoutRootView(this._owner, parentBounds);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this._owner._updateLayout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public viewWillAppear() {
|
public viewWillAppear() {
|
||||||
@ -56,12 +62,20 @@ class UIViewControllerImpl extends UIViewController {
|
|||||||
export class Page extends pageCommon.Page {
|
export class Page extends pageCommon.Page {
|
||||||
private _ios: UIViewController;
|
private _ios: UIViewController;
|
||||||
public _enableLoadedEvents: boolean;
|
public _enableLoadedEvents: boolean;
|
||||||
|
public _isModal: boolean = false;
|
||||||
|
|
||||||
constructor(options?: definition.Options) {
|
constructor(options?: definition.Options) {
|
||||||
super(options);
|
super(options);
|
||||||
this._ios = UIViewControllerImpl.new().initWithOwner(this);
|
this._ios = UIViewControllerImpl.new().initWithOwner(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public requestLayout(): void {
|
||||||
|
super.requestLayout();
|
||||||
|
if (!this.parent && this.ios && this._nativeView) {
|
||||||
|
this._nativeView.setNeedsLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public _onContentChanged(oldView: viewModule.View, newView: viewModule.View) {
|
public _onContentChanged(oldView: viewModule.View, newView: viewModule.View) {
|
||||||
super._onContentChanged(oldView, newView);
|
super._onContentChanged(oldView, newView);
|
||||||
this._removeNativeView(oldView);
|
this._removeNativeView(oldView);
|
||||||
@ -110,12 +124,12 @@ export class Page extends pageCommon.Page {
|
|||||||
return this._ios;
|
return this._ios;
|
||||||
}
|
}
|
||||||
|
|
||||||
get _nativeView(): any {
|
get _nativeView(): UIView {
|
||||||
return this.ios.view;
|
return this.ios.view;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _showNativeModalView(parent: Page, context: any, closeCallback: Function, fullscreen?: boolean) {
|
protected _showNativeModalView(parent: Page, context: any, closeCallback: Function, fullscreen?: boolean) {
|
||||||
(<any>this)._isModal = true;
|
this._isModal = true;
|
||||||
|
|
||||||
if (!parent.ios.view.window) {
|
if (!parent.ios.view.window) {
|
||||||
throw new Error("Parent page is not part of the window hierarchy. Close the current modal page before showing another one!");
|
throw new Error("Parent page is not part of the window hierarchy. Close the current modal page before showing another one!");
|
||||||
@ -143,7 +157,7 @@ export class Page extends pageCommon.Page {
|
|||||||
|
|
||||||
protected _hideNativeModalView(parent: Page) {
|
protected _hideNativeModalView(parent: Page) {
|
||||||
parent._ios.dismissModalViewControllerAnimated(false);
|
parent._ios.dismissModalViewControllerAnimated(false);
|
||||||
(<any>this)._isModal = false;
|
this._isModal = false;
|
||||||
(<any>this)._UIModalPresentationFormSheet = false;
|
(<any>this)._UIModalPresentationFormSheet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user