nativescript - Nativescript - Tabview 闪烁过渡
问题描述
我在模拟器 ( Nougat v7.1.1 ) 或设备 ( Oreo 8.1 ) 上使用 Angular 、Android、Nativescript (V4)的“Tab Navigation”模板遇到问题。
当我在选项卡之间导航时,屏幕“闪烁”。该行为似乎与使用多个“page-router-outlet”有关。
我尝试了Nativescript Forum描述的解决方案,但没有成功。
在<item name=“android:windowAnimationStyle”>@null</item>
AppThemeBase 中,我遇到了一个类型的错误
System.err: com.tns.NativeScriptException:
System.err: Calling js method onViewAttachedToWindow failed
System.err:
System.err: TypeError: Cannot set property 'transitionType' of null
(在模拟器或设备上)。
如果有人有想法?:)
解决方案
我们发现这个问题与 NativeScript 核心模块中的两个关键问题有关:
- 对于 iOS,我们需要一种方法来更早地隐藏导航栏并且没有动画,即:
constructor(frame: Frame) {
this._controller = UINavigationControllerImpl.initWithOwner(new WeakRef(frame));
// This needs to be set early to avoid white flashes when changing page-router-outlets preferably in the constructor for iOS frame
this._controller.setNavigationBarHiddenAnimated(true, false);
}
我们还发现,iOS 在构造控制器时为它们设置透明背景很有帮助,即在page.ios.ts
发生这种情况的位置:
const controller = UIViewControllerImpl.initWithOwner(new WeakRef(this));
this.viewController = this._ios = controller;
// controller.view.backgroundColor = whiteColor; (This is what it's doing now which obviously could cause a white flash)
controller.view.backgroundColor = new Color("#00000000").ios; // instead could ensure transparent to start
- 在 Android 上,修复位于 nativescript-angular PR 中: https ://github.com/NativeScript/nativescript-angular/pull/1569
更多讨论: https ://github.com/NativeScript/NativeScript/issues/6454#issuecomment-433176056
推荐阅读
- javascript - ChartJS 工具提示滚动条防止数据溢出?
- javascript - 我必须避免在我的数字键盘上输入字母
- android - 在 Android Studio Kotlin 中从 SQLite 数据库中删除数据
- excel - 宏记录在另一张纸上:“运行时错误'-2147024809(80070057)':指定的值超出范围”
- nginx - Nextcloud snap & nginx 反向代理
- powershell - PowerShell 获取具有最大属性值的注册表项
- amazon-web-services - 仅从浏览器使用预签名 URL 上传时出现 AWS S3 CORS 错误
- javascript - 是否可以将外部 js 文件/库加载到 Acumatica 中?
- sql - 如何使用 SQL 计算 BigQuery 中的每周留存率
- excel - 在 VBA 中打开 Word 文档会导致空变量