方向变化更新视图
Update view on orientation change
我注册了这样的 orientationChangedEvent:
app.on(app.orientationChangedEvent, (args: OrientationChangedEventData) => {
if (this.currentScreenWidth === screen.mainScreen.widthDIPs) {
this.currentScreenWidth = screen.mainScreen.heightDIPs;
} else {
this.currentScreenWidth = screen.mainScreen.widthDIPs;
}
this.configureGrid();
});
我有以下模板:
<GridLayout [rows]="rows" [columns]="columns">
<ng-container *ngFor="let card of cards">
<StackLayout [row]="card.row" [col]="card.col" [colSpan]="card.colSpan">
<kirby-card>
<kirby-card-header [title]="'row: ' + card.row" [subtitle]="'col: ' + card.col">
</kirby-card-header>
<StackLayout class="content">
<Label text="Here you can add stuff, which is cool."></Label>
</StackLayout>
<kirby-card-footer>
<kirby-button label="Dummy Kirby Button" expand="block" shape="round" theme="cookbook"></kirby-button>
</kirby-card-footer>
</kirby-card>
</StackLayout>
</ng-container>
在我的 configureGrid 方法中,我更新了行、列和卡片属性,但我的视图没有更新,视图 (GridLayout) 只是显示与旋转之前完全相同。我已经注销了所有的数据,我的数据确实发生了变化,所以数据绑定似乎没有理解数据发生了变化。
我能否以某种方式强制更新视图,或者我该如何解决这个问题?
谢谢
用NgZone做数据更新,一切正常。
我注册了这样的 orientationChangedEvent:
app.on(app.orientationChangedEvent, (args: OrientationChangedEventData) => {
if (this.currentScreenWidth === screen.mainScreen.widthDIPs) {
this.currentScreenWidth = screen.mainScreen.heightDIPs;
} else {
this.currentScreenWidth = screen.mainScreen.widthDIPs;
}
this.configureGrid();
});
我有以下模板:
<GridLayout [rows]="rows" [columns]="columns">
<ng-container *ngFor="let card of cards">
<StackLayout [row]="card.row" [col]="card.col" [colSpan]="card.colSpan">
<kirby-card>
<kirby-card-header [title]="'row: ' + card.row" [subtitle]="'col: ' + card.col">
</kirby-card-header>
<StackLayout class="content">
<Label text="Here you can add stuff, which is cool."></Label>
</StackLayout>
<kirby-card-footer>
<kirby-button label="Dummy Kirby Button" expand="block" shape="round" theme="cookbook"></kirby-button>
</kirby-card-footer>
</kirby-card>
</StackLayout>
</ng-container>
在我的 configureGrid 方法中,我更新了行、列和卡片属性,但我的视图没有更新,视图 (GridLayout) 只是显示与旋转之前完全相同。我已经注销了所有的数据,我的数据确实发生了变化,所以数据绑定似乎没有理解数据发生了变化。
我能否以某种方式强制更新视图,或者我该如何解决这个问题?
谢谢
用NgZone做数据更新,一切正常。