2016-04-04 71 views
0

我的問題是,如果我可以得到使用科爾多瓦工作的android應用程序的IOS版本?我曾嘗試添加了一個平臺這樣的:是否有可能從工作的Android應用程序與科爾多瓦生成iOS應用程序?

//I add the platform 
cordova platform add ios 
//I compile the project 
cordova build ios 

然後我嘗試運行它,但它的工作原理很糟糕,它加載一個空白的屏幕,該項目其運行說道。我認爲它是一個配置問題。自動創建config.xml文件(IOS)是這樣的:

<?xml version='1.0' encoding='utf-8'?> 
<widget id="com.project.appios" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
    <preference name="AllowInlineMediaPlayback" value="false" /> 
    <preference name="BackupWebStorage" value="cloud" /> 
    <preference name="DisallowOverscroll" value="false" /> 
    <preference name="EnableViewportScale" value="false" /> 
    <preference name="KeyboardDisplayRequiresUserAction" value="true" /> 
    <preference name="MediaPlaybackRequiresUserAction" value="false" /> 
    <preference name="SuppressesIncrementalRendering" value="false" /> 
    <preference name="SuppressesLongPressGesture" value="false" /> 
    <preference name="Suppresses3DTouchGesture" value="false" /> 
    <preference name="GapBetweenPages" value="0" /> 
    <preference name="PageLength" value="0" /> 
    <preference name="PaginationBreakingMode" value="page" /> 
    <preference name="PaginationMode" value="unpaginated" /> 
    <feature name="LocalStorage"> 
     <param name="ios-package" value="CDVLocalStorage" /> 
    </feature> 
    <feature name="HandleOpenUrl"> 
     <param name="ios-package" value="CDVHandleOpenURL" /> 
     <param name="onload" value="true" /> 
    </feature> 
    <feature name="IntentAndNavigationFilter"> 
     <param name="ios-package" value="CDVIntentAndNavigationFilter" /> 
     <param name="onload" value="true" /> 
    </feature> 
    <feature name="GestureHandler"> 
     <param name="ios-package" value="CDVGestureHandler" /> 
     <param name="onload" value="true" /> 
    </feature> 
    <feature name="Camera"> 
     <param name="ios-package" value="CDVCamera" /> 
    </feature> 
    <preference name="CameraUsesGeolocation" value="false" /> 
    <feature name="File"> 
     <param name="ios-package" value="CDVFile" /> 
     <param name="onload" value="true" /> 
    </feature> 
    <feature name="Geolocation"> 
     <param name="ios-package" value="CDVLocation" /> 
    </feature> 
    <feature name="Media"> 
     <param name="ios-package" value="CDVSound" /> 
    </feature> 
    <feature name="Capture"> 
     <param name="ios-package" value="CDVCapture" /> 
    </feature> 
    <feature name="Contacts"> 
     <param name="ios-package" value="CDVContacts" /> 
    </feature> 
    <feature name="FileTransfer"> 
     <param name="ios-package" value="CDVFileTransfer" /> 
    </feature> 
    <feature name="InAppBrowser"> 
     <param name="ios-package" value="CDVInAppBrowser" /> 
    </feature> 
    <content src="index.html" /> 
    <access origin="*" /> 
    <allow-navigation href="*" /> 
    <allow-intent href="*" /> 
</widget> 

根config.xml文件看起來是這樣的:

<?xml version='1.0' encoding='utf-8'?> 
<widget id="com.medife.appios" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
    <name>*****</name> 
    <description> 
     ****************** 
    </description> 
    <author email="*******************************"> 
     ********* 
    </author> 
    <content src="index.html" /> 
    <plugin name="cordova-plugin-whitelist" spec="1" /> 
    <access origin="*" /> 
    <allow-navigation href="*" /> 
    <allow-intent href="*" /> 
    <preference name="SplashScreen" value="screen"/> 
    <preference name="SplashScreenDelay" value="5000" /> 
    <preference name="ShowSplashScreenSpinner" value="false" /> 
    <preference name="orientation" value="portrait" /> 
    <platform name="android"> 
    <!-- you can use any density that exists in the Android project --> 
     <splash src="res/screen/android/splash-port-hdpi.png" density="port-hdpi"/> 
     <splash src="res/screen/android/splash-port-ldpi.png" density="port-ldpi"/> 
     <splash src="res/screen/android/splash-port-mdpi.png" density="port-mdpi"/> 
     <splash src="res/screen/android/splash-port-xhdpi.png" density="port-xhdpi"/> 
    </platform> 
    <platform name="ios"> 
     <!-- images are determined by width and height. The following are supported --> 
     <splash src="res/screen/ios/default-568-iphone.png" width="640" height="1136"/> 
     <splash src="res/screen/ios/default-667-iphone.png" width="750" height="1334"/> 
     <splash src="res/screen/ios/default-736-iphone.png" width="1242" height="2208"/> 
    </platform> 
    <icon src="res/logo/logo.png" /> 
</widget> 

我已刪除作者,描述和電子郵件...

更新:我已經注意到,在XCode控制檯,一些插件丟失,所以即時檢查其他stackoverflow關於這個問題的答案。我認爲是因爲該應用程序的後端是使用較舊版本的iOS製作的。

在此先感謝!

+0

可能只需要在配置ios時執行'Cordova Prepare'。 –

+0

@Edu,您使用的是哪個版本的iOS?任何錯誤跟蹤?你在你的應用程序中做Ajax調用來呈現頁面嗎? – Gandhi

+0

@Gandhi即時通訊使用最新版本的iOS,至少我更新到最新版本。我沒有錯誤跟蹤,但查找jquery錯誤更困難,因爲我無法在iOS中使用Google開發人員工具。我在做Ajax調用但不在渲染中。我也提到它,但它在Android上工作得很好。一些我沒有提到,但也許有所幫助的是,我沒有設置splashscreen。 – Elver

回答

0

最後我明白了。我張貼的答案,所以如果有人遇到同樣的問題,它可以幫助:

首先幾件事: 1)沒有問題的啓動畫面插件,它的工作真的很好,我剛更新它,它很漂亮。 2)我不得不改變一些jQuery的,因爲它不會在iOS上運行良好: 我改變

$(document).ready(function() { 
    onDeviceReady(); 
}); 

隨着

document.addEventListener('deviceready', onDeviceReady, false); 

最後,這是我的config.xml(在兩個Android平臺和iOS):

<?xml version='1.0' encoding='utf-8'?> 
<widget id="com.medife.mobile" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
    <name>APP NAME</name> 
    <description> 
     YOUR DESCRIPTION 
    </description> 
    <author email="YOURMAIL" href=""> 
     YOUR NAME 
    </author> 
    <content src="index.html" /> 
    <access origin="*" /> 
    <allow-navigation href="*" /> 
    <allow-intent href="*" /> 
    <preference name="SplashScreen" value="screen" /> 
    <preference name="SplashScreenDelay" value="7500" /> 
    <preference name="ShowSplashScreenSpinner" value="false" /> 
    <preference name="orientation" value="portrait" /> 
    <preference name="AutoHideSplashScreen" value="false" /> 
    <platform name="android"> 
     <splash density="port-hdpi" src="res/screen/android/splash-port-hdpi.png" /> 
     <splash density="port-ldpi" src="res/screen/android/splash-port-ldpi.png" /> 
     <splash density="port-mdpi" src="res/screen/android/splash-port-mdpi.png" /> 
     <splash density="port-xhdpi" src="res/screen/android/splash-port-xhdpi.png" /> 
    </platform> 
    <platform name="ios"> 
     <splash src="res/screen/ios/[email protected]~iphone.png" width="640" height="1136"/> 
     <splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/> 
     <splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/> 
    </platform> 
    <icon src="res/logo/logo.png" /> 
    <plugin name="cordova-plugin-whitelist" spec="~1.2.1" /> 
    <plugin name="cordova-plugin-splashscreen" spec="~3.2.1" /> 
    <plugin name="cordova-plugin-geolocation" spec="~2.1.0" /> 
    <plugin name="cordova-plugin-camera" spec="~2.1.1" /> 
    <plugin name="cordova-plugin-contacts" spec="~2.0.1" /> 
    <plugin name="cordova-plugin-file" spec="~4.1.1" /> 
    <plugin name="cordova-plugin-file-transfer" spec="~1.5.0" /> 
    <plugin name="cordova-plugin-inappbrowser" spec="~1.3.0" /> 
</widget> 

我守時的問題是,我使用window.outerHeightwindow.outerWidth得到高度和寬度,我t沒有在ios上工作,我不得不使用window.innerHeightwindow.innerWidth

相關問題