nativescript - Alert is not visible in nativescript ios after autocomplete usage
问题描述
I am working on a nativescript app for android and ios in which I have used REST APIs to store/get data in JSON format. Based on JSON result from APIs sometime I need to show alert to the user. It was working fine with Nativescript 4.1 but since I have upgraded to 4.2 app is unable to show alert boxs in ios. It shows the blank page and shows the following error.
(UIKitCore) Warning: Attempt to present <UIAlertController: 0x7fb5834eb000> on <UIViewControllerImpl: 0x7fb58659a670> whose view is not in the window hierarchy!
I have suspected that I am calling alert too early so I have tried to add timeout before alert but still it's the same.
if (result.status === 'E') {
setTimeout(function () {
const alertOptions = { title: 'Error', message: result.errMsg, okButtonText: 'OK', cancelable: false };
dialogs.alert(alertOptions).then(() => {
resolve('Error');
});
}, 700);
Points to note here is I am using nativescript-autocomplete component in one of my tabs. and this problem occurs only when user searches something using that component. So it could be something related to that component.May be when autocomplete closes the modal, app looses the parent reference ?
解决方案
暂时找到了临时解决方案。 nativescript-fancyalert就像一个魅力。会坚持一段时间。它基于ios 的SCLAlertView。
推荐阅读
- java - 是否可以构建除 java 和 c/cpp 之外的 android 应用程序?
- vba - 条件格式 - 如何引用单元格本身?
- assembly - 如何正确使用FDIV?集会
- angular - 有没有办法以百分比指定 ag-grid 列宽?
- angular - Angular Http请求未填充数据
- javascript - 希腊字母未显示在我的网络浏览器页面中
- r - UCI 机器学习存储库数据集
- wpf - 使用 Windows 远程桌面连接时出现 OnRenderSurfaceBaseLoaded 空异常
- jquery - jQuery 在表单中不起作用
- c# - Kinect V2 - 存储点位置时重复值