我正在为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失去了父引用?