代码之家  ›  专栏  ›  技术社区  ›  Narendra

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

  •  1
  • Narendra  · 技术社区  · 7 年前

    我正在为android和ios开发一个nativescript应用程序,其中我使用restapi以JSON格式存储/获取数据。 基于API的JSON结果,有时我需要向用户显示警报。

    (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 我的一个选项卡中的组件。只有当用户使用该组件搜索某个对象时,才会出现此问题。 所以它可能与该组件有关。可能是当autocomplete关闭模态时,app失去了父引用?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Narendra    7 年前

    找到了暂时的解决办法。 nativescript-fancyalert 很有魅力。会坚持一段时间。 SCLAlertView