2016-07-18 6 views
0

AngularとCordovaについての新しいことです。 私はCordova 6.2と1.5.6を使用しています。 新しいコードバプロジェクトを作成するとプラグインが動作することがありますが、私の角型アプリケーションではできません。私の問題は、IOSシステムでStatusBarOverlaysWebView = falseを設定しなければならなかったときに生まれ、(iphone 5s、iphone 6、エミュレータの両方で)動作させることができませんでした。私は他のプラグインを使用しようとしましたが、何も動作しませんでした。 私はグーグルで、角度がロードされた後で問題がプラグインを呼び出す可能性があり、プラグインが動作する(アプリケーション/デバイスが準備完了した後に呼び出す)ために手動でブートストラップする必要があることを発見しました。 私は指示に従って試してみましたが、私はこの仕事を得ることができません。 私は、コード準備が整ったイベントのコードを、新しいコードバスプロジェクトのコードバスデバイスの準備ができているベースのコードからコピーすることはできません。コードオフと角度:プラグインが機能しない

IOSで動作しているステータスバー、スプラッシュスクリーンも取得できません。

多分、私はちょっとしたことを見逃しています。

ここに私のコードです、ありがとう!私は追加する必要が

myApp.js

window.addEventListener('deviceready', function onDeviceReady() { 
    //Never fired!!!!!! 
    console.log("readydevice"); 
    StatusBar.overlaysWebView(false); 
    angular.bootstrap(document, ['myApp']); 
    StatusBar.overlaysWebView(false); 

}, false); 

window.addEventListener('DOMContentLoaded', function onDeviceReady() { 
    //Fired but console returns: StatusBar is not defined 
    console.log("readyDom"); 
    StatusBar.overlaysWebView(false); 
    angular.bootstrap(document.body, ['myApp']); 
    StatusBar.overlaysWebView(false); 

}, false); 



angular.module('myApp', [ 
    'ngRoute', 
    'mobile-angular-ui', 
    'ngSanitize' 
]); 

index.htmlを

<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"/> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> 
    <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0"/> 
    <title>My app</title> 
    <link rel="stylesheet" href="dist/css/mobile-angular-ui-base.min.css"/> 
    <link rel="stylesheet" href="dist/css/general.css"/> 
    <link rel="stylesheet" href="dist/css/custom.css"/> 
    <script src="dist/js/winstore-jscompat.js"></script> 
    <script src="dist/js/angular.min.js"></script> 
    <script src="dist/js/angular-route.min.js"></script> 
    <script src="dist/js/angular-sanitize.min.js"></script> 
    <script src="dist/js/mobile-angular-ui.min.js"></script> 
    <script src="dist/js/mobile-angular-ui.gestures.min.js"></script> 
    <script src="javascript/config.js"></script> 

</head> 
<body ng-csp=""> 

<div class="app"> 
    <top-bar></top-bar> 

    <div class="app-body"> 
     <div ng-view class="app-content scrollable-content"></div> 
    </div> 

    <menu-bottom></menu-bottom> 

</div> 

<script src="javascript/myApp.js"></script> 
<script src="javascript/controllers/route.js"></script> 
<script src="javascript/controllers/controller.js"></script> 
<script src="javascript/directives/directive.js"></script> 
</body> 
</html> 

config.xmlの

<?xml version='1.0' encoding='utf-8'?> 
<widget id="com.example.com" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
    <name>My App</name> 
    <description> 
     My App 
    </description> 
    <author email="[email protected]" href="http://www.example.com"> 
     My Team 
    </author> 
    <content src="index.html" /> 
    <access origin="*" /> 
    <access launch-external="yes" origin="tel:*" /> 
    <access launch-external="yes" origin="mailto:*" /> 
    <engine name="ios" spec="~4.1.1" /> 
    <engine name="android" spec="~5.1.1" /> 
    <engine name="windows" spec="~4.3.2" /> 
    <allow-intent href="http://*/*" /> 
    <allow-intent href="https://*/*" /> 
    <allow-intent href="tel:*" /> 
    <allow-intent href="sms:*" /> 
    <allow-intent href="mailto:*" /> 
    <allow-intent href="geo:*" /> 
    <preference name="AutoHideSplashScreen" value="true" /> 
    <preference name="splashscreen" value="splash" /> 
    <preference name="SplashScreenDelay" value="1000" /> 
    <preference name="Fullscreen" value="false" /> 
    <preference name="DisallowOverscroll" value="true" /> 
    <preference name="Orientation" value="portrait" /> 
    <preference name="StatusBarOverlaysWebView" value="false" /> 
    <preference name="StatusBarBackgroundColor" value="#000000" /> 
    <preference name="StatusBarStyle" value="default" /> 
    <platform name="android"> 
     <allow-intent href="market:*" /> 
     <!--<splash density="land-hdpi" src="res/images/splash.png" />--> 
     <!--<splash density="port-hdpi" src="res/images/splash.png" />--> 
    </platform> 
    <platform name="ios"> 
     <allow-intent href="itms:*" /> 
     <allow-intent href="itms-apps:*" /> 
     <preference name="SuppressesIncrementalRendering" value="true" /> 
     <!--<splash src="res/images/ios/Default~iphone.png" width="320" height="480"/>--> 
     <!--<splash src="res/images/ios/[email protected]~iphone.png" width="640" height="960"/>--> 
    </platform> 
    <icon src="res/images/icon.png" /> 

</widget> 
+1

どのようにプロジェクトをセットアップしましたか? '' script type = "text/javascript" src = "cordova.js"> '....のようなコードバを含めていないようです。 – Phonolog

+0

今日は同じ疑いがありました。私がwindow.cordovaを記録した場合、常にnullが得られます。私は公式サイトhttps://cordova.apache.org/docs/en/latest/guide/cli/のガイドに沿ってcordova cliによってセットアップしました 私はwwwの下にスクリプトを追加しようとしましたが、結果はありません。もし私がプラットフォームにapk/appx/ipaをビルドすると私はcordova jsを参照してください。何が間違っているのですか?ありがとう! – SBO

+1

もし私がcli(v 6.2.0)で新しいプロジェクトをセットアップすると、index.htmlのcordova.jsへの参照がはっきりとわかります。あなたのプロジェクトの作成を再試行し、失敗した場合はcordovaの更新をお勧めします。 – Phonolog

答えて

0

<script type="text/javascript" src="cordova.js"></script> 

(index.html)。

関連する問題