使用自动完成后,在 nativescript ios 中不可见警报

Alert is not visible in nativescript ios after autocomplete usage

我正在为 android 和 ios 开发一个 nativescript 应用程序,我在其中使用 REST API 来处理 store/get 格式的 JSON 数据。 根据 API 的 JSON 结果,有时我需要向用户显示警报。 它在 Nativescript 4.1 上运行良好,但自从我升级到 4.2 后,应用程序无法在 ios 中显示警告框。它显示空白页并显示以下错误。

(UIKitCore) Warning: Attempt to present <UIAlertController: 0x7fb5834eb000> on <UIViewControllerImpl: 0x7fb58659a670> whose view is not in the window hierarchy!

我怀疑我调用警报太早了,所以我尝试在警报之前添加超时,但仍然是一样的。

if (result.status === 'E') {
                setTimeout(function () {
                    const alertOptions = { title: 'Error', message: result.errMsg, okButtonText: 'OK', cancelable: false };
                    dialogs.alert(alertOptions).then(() => {
                        resolve('Error');
                    });
                }, 700);

这里要注意的是我在我的一个选项卡中使用了 nativescript-autocomplete 组件。并且仅当用户使用该组件搜索某些内容时才会出现此问题。 所以这可能与 component.May 相关,当自动完成关闭模态时,应用程序会丢失父引用 ?

暂时找到一个临时解决方案。 nativescript-fancyalert 很有魅力。会坚持一段时间。 它基于 SCLAlertView for ios.