apache cordova ios toast 和 spinner 对话问题

Posted

技术标签:

【中文标题】apache cordova ios toast 和 spinner 对话问题【英文标题】:apache cordova ios toast and spinner dialogue issue 【发布时间】:2017-02-01 12:14:47 【问题描述】:

我正在开发适用于 androidios 构建的 apache Cordova 应用程序。 在使用 android 时,我添加了不必要的离子键盘。但它没有给Android构建带来任何问题。但是当我使用 ios toast 和 spinner 时,对话不起作用。 另一个项目之一在 ios 和 android build 上运行良好。

    当我从 config.xml 中删除离子键盘时,它根本无法工作。 当我再次使用“cordova plugin add ionic-plugin-keyboard --save”时,此插件微调器对话框有效,但即使我使用 window.plugins.spinnerDialog.hide(),它也不会再次隐藏; 假设如果我点击登录按钮时出现登录屏幕,则 toast 通知不起作用,但当我点击输入字段时,它会立即显示示例(“用户名/密码无效”或我写的任何相关消息)。 当我查看 xcode 编译器消息时...它显示“线程警告:['Toast'] 花费了 '79.340088' 毫秒。插件应该使用后台线程。

<!DOCTYPE html>
<html ng-app="myapp">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy" content="default-src *; img-src 'self' data:;style-src 'self' http://* 'unsafe-inline'; script-src 'self'  http://* 'unsafe-inline' 'unsafe-eval'">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>
    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/app.css" rel="stylesheet">
    <link href="lib/ion-md-input/css/ion-md-input.min.css" rel="stylesheet">
    <link href="lib/ionic-material/dist/ionic.material.min.css" rel="stylesheet" />
    <!--<link href='https://fonts.googleapis.com/css?family=RobotoDraft:400,500,700,400italic' rel='stylesheet' type='text/css'>-->
    <link href="lib/ionic-material/dist/ionic.material.css" rel="stylesheet" />
    <link href="css/style.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet" />
    <link href="css/sweetalert.css" rel="stylesheet" />
    <link href="css/slidingTabs.css" rel="stylesheet" />     
  
       
    <!--<link href="https://fonts.googleapis.com/css?family=Lato:400" rel="stylesheet">-->
</head>
<body>
    <ion-nav-bar class="bar-balanced">
        <ion-nav-back-button>
        </ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view></ion-nav-view>
    <div class="spinner">
        <ion-spinner icon="android" class="spinnerSpinner"></ion-spinner>
        <div class="spinnerBackground"></div>
    </div>
rc="lib/ionic/js/ionic.bundle.js"></script>
    <script src="lib/ionic-material/dist/ionic.material.min.js"></script>
    <script src="lib/ion-md-input/js/ion-md-input.min.js"></script>
    <script src="lib/sweetalert.min.js"></script>
    <script src="scripts/slidingTabsDirective.js"></script>
    <script src="scripts/ng-cordova.min.js"></script>
    <script src="lib/ionic-toast/dist/ionic-toast.bundle.min.js"></script>
    <script type="text/javascript" src="scripts/qrcode.min.js"></script>
    <!-- Cordova references -->
    <script src="cordova.js"></script>
    <script src="scripts/platformOverrides.js"></script>
    <!-- App references -->
    <script src="scripts/index.js"></script>
    <script src="app/directives.js"></script>
    <script src="app/services.js"></script>
    <script src="app/controllers.js"></script>
    <script src="app/app.js"></script>
</body>
</html>

这是我的 index.html

<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="" defaultlocale="en-US" id="io.cordova.DealNSumConsumer" version="1.0.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps">
    <name>DealnSum</name>
    <description>A blank project that uses Apache Cordova to help you build an app that targets multiple mobile platforms: Android, iOS, Windows, and Windows Phone.</description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">Apache Cordova Team </author>
    <content src="index.html" />
    <access origin="https://dealnsum.com/" />
    <vs:features />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-navigation href="http://*/*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="4000" />
    <preference name="SplashMaintainAspectRatio" value="true|false" />
    <preference name="SplashShowOnlyFirstTime" value="true|false" />
    <platform name="android">
        <icon density="ldpi" src="res/icons/android/icon-36-ldpi.png" />
        <icon density="mdpi" src="res/icons/android/icon-48-mdpi.png" />
        <icon density="hdpi" src="res/icons/android/icon-72-hdpi.png" />
        <icon density="xhdpi" src="res/icons/android/icon-96-xhdpi.png" />
        <splash src="res/screens/android/logo-new-714.png" />
        <splash density="port-ldpi" src="res/screens/android/logo-new-714.png" />
        <splash density="port-mdpi" src="res/screens/android/logo-new-714.png" />
        <splash density="port-xhdpi" src="res/screens/android/logo-new-714.png" />
    </platform>
    <platform name="ios">
        <icon  src="res/icons/ios/icon-60-3x.png"  />
        <icon  src="res/icons/ios/icon-60.png"  />
        <icon  src="res/icons/ios/icon-60-2x.png"  />
        <icon  src="res/icons/ios/icon-76.png"  />
        <icon  src="res/icons/ios/icon-76-2x.png"  />
        <icon  src="res/icons/ios/icon-40.png"  />
        <icon  src="res/icons/ios/icon-40-2x.png"  />
        <icon  src="res/icons/ios/icon-57.png"  />
        <icon  src="res/icons/ios/icon-57-2x.png"  />
        <icon  src="res/icons/ios/icon-72.png"  />
        <icon  src="res/icons/ios/icon-72-2x.png"  />
        <icon  src="res/icons/ios/icon-small.png"  />
        <icon  src="res/icons/ios/icon-small-2x.png"  />
        <icon  src="res/icons/ios/icon-50.png"  />
        <icon  src="res/icons/ios/icon-50-2x.png"  />
    </platform>
    <platform name="windows">
        <icon  src="res/icons/windows/Square150x150Logo.scale-100.png"  />
        <icon  src="res/icons/windows/Square150x150Logo.scale-240.png"  />
        <icon  src="res/icons/windows/Square30x30Logo.scale-100.png"  />
        <icon  src="res/icons/windows/Square310x310Logo.scale-100.png"  />
        <icon  src="res/icons/windows/Square44x44Logo.scale-100.png"  />
        <icon  src="res/icons/windows/Square44x44Logo.scale-240.png"  />
        <icon  src="res/icons/windows/Square70x70Logo.scale-100.png"  />
        <icon  src="res/icons/windows/Square71x71Logo.scale-100.png"  />
        <icon  src="res/icons/windows/Square71x71Logo.scale-240.png"  />
        <icon  src="res/icons/windows/StoreLogo.scale-100.png"  />
        <icon  src="res/icons/windows/StoreLogo.scale-240.png"  />
        <icon  src="res/icons/windows/Wide310x150Logo.scale-100.png"  />
        <icon  src="res/icons/windows/Wide310x150Logo.scale-240.png"  />
    </platform>
    <platform name="wp8">
        <icon  src="res/icons/wp8/ApplicationIcon.png"  />
        <icon  src="res/icons/wp8/Background.png"  />
    </platform>
    <platform name="ios">
        <splash  src="res/screens/ios/screen-iphone-portrait.png"  />
        <splash  src="res/screens/ios/screen-iphone-portrait-2x.png"  />
        <splash  src="res/screens/ios/screen-ipad-portrait.png"  />
        <splash  src="res/screens/ios/screen-ipad-portrait-2x.png"  />
        <splash  src="res/screens/ios/screen-ipad-landscape.png"  />
        <splash  src="res/screens/ios/screen-ipad-landscape-2x.png"  />
        <splash  src="res/screens/ios/screen-iphone-568h-2x.png"  />
        <splash  src="res/screens/ios/screen-iphone-portrait-667h.png"  />
        <splash  src="res/screens/ios/screen-iphone-portrait-736h.png"  />
        <splash  src="res/screens/ios/screen-iphone-landscape-736h.png"  />
    </platform>
    <platform name="windows">
        <splash  src="res/screens/windows/SplashScreen.scale-100.png"  />
        <splash  src="res/screens/windows/SplashScreen.scale-240.png"  />
        <splash  src="res/screens/windows/SplashScreenPhone.scale-240.png"  />
    </platform>
    <platform name="wp8">
        <splash  src="res/screens/wp8/SplashScreenImage.png"  />
    </platform>
    <plugin name="cordova-plugin-android-permissions" version="0.10.0" />
    <plugin name="cordova-plugin-compat" version="1.0.0" />
    <plugin name="cordova-plugin-x-toast" version="2.5.2" />
    <preference name="Orientation" value="default" />
    <preference name="Fullscreen" value="False" />
    <plugin name="cordova-plugin-inappbrowser" version="1.5.0" />
    <plugin name="cordova-plugin-splashscreen" version="4.0.1-dev" />
    <plugin name="cordova-plugin-whitelist" version="1.3.0" />
    <plugin name="cordova-plugin-spinner" version="1.1.0" />
    <plugin name="cordova-plugin-spinner-dialog" src="https://github.com/Paldom/SpinnerDialog.git" version="1.3.1" />
    <plugin name="cordova-plugin-actionsheet" version="2.3.1" />
    <plugin name="cordova-plugin-network-information" version="1.3.0" />
    <plugin name="cordova-plugin-camera" version="2.2.0" />
    <plugin name="cordova-plugin-crop" version="0.1.0" />
    <plugin name="cordova-sqlite-storage" version="1.4.9" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
</widget>

这是我的 config.xml

提前致谢,

【问题讨论】:

【参考方案1】:

我解决了这个问题...问题出在 index.html 上。 我已在 index.html 中添加了以下行,因此由于某些应用程序标准,它无法正常工作。

 <meta http-equiv="Content-Security-Policy" content="default-src *; img-src 'self' data:;style-src 'self' http://* 'unsafe-inline'; script-src 'self'  http://* 'unsafe-inline' 'unsafe-eval'">

删除 index.html 中的上述行后,现在可以正常工作了

【讨论】:

以上是关于apache cordova ios toast 和 spinner 对话问题的主要内容,如果未能解决你的问题,请参考以下文章

Apache cordova iOS 图标未部署

静止不动时,Apache Cordova geolocation.watchPosition() 在 iOS 上超时

用于 Apache Cordova 的 VS 2015 工具 - iOS 远程构建不使用 buildServer

Visual Studio Apache Cordova - iOS 在运行时构建缺少的 Javascript 文件

用于 Visual Studio 的 Apache cordova 在构建期间不会更新 iOS 平台文件

即使安装了本机应用程序,iOS 上的 Apache Cordova Facebook 插件也始终打开 Web 对话框