我正在使用带有SQLite的Phonegap为iOS制作应用程序。 在deviceready()中,我从JSON文件加载SQLite表。
CODE:
document.addEventListener("deviceready", onDeviceReady, false);
var db;
function onDeviceReady() {
try
{
window.requestFileSystem(LocalFileSystem.PERSISTENT, 2048*1024, FileIO.gotFS, FileIO.errorHandler);
db = window.sqlitePlugin.openDatabase({ name: "ValeDB", location: 1 });
db.transaction(function(tx) {
tx.executeSql('DROP TABLE IF EXISTS tbl_Location');
tx.executeSql('DROP TABLE IF EXISTS tbl_OrgUnit');
tx.executeSql('CREATE TABLE IF NOT EXISTS tbl_Location (id integer, value text)');
tx.executeSql('CREATE TABLE IF NOT EXISTS tbl_OrgUnit (id integer, value text, type text)');
LocationList.forEach(function(loc){
//console.log(loc.value);
tx.executeSql("INSERT INTO tbl_Location (id, value) VALUES (?, ?)", [loc.id, loc.value],
function(tx, res){
//console.log("Success: " + res.insertId);
},
function(e){
console.log("Error: " + e.message);
});
});
tx.executeSql("SELECT COUNT(*) AS Count FROM tbl_Location", [], function(tx, res){
if(res.rows.length > 0)
console.log("New rows added to tbl_Location:" + res.rows.item(0).Count);
});
EnglishOrgUnit.forEach(function(org){
//console.log(loc.value);
tx.executeSql("INSERT INTO tbl_OrgUnit (id, value, type) VALUES (?, ?, ?)", [org.id, org.value, "en"],
function(tx, res){
//console.log("Success: " + res.insertId);
},
function(e){
console.log("Error: " + e.message);
});
});
tx.executeSql("SELECT COUNT(*) AS Count FROM tbl_OrgUnit WHERE TYPE = 'en'", [], function(tx, res){
if(res.rows.length > 0)
console.log("New Eng. rows added to tbl_OrgUnit:" + res.rows.item(0).Count);
});
PortugueseOrgUnit.forEach(function(org){
//console.log(loc.value);
tx.executeSql("INSERT INTO tbl_OrgUnit (id, value, type) VALUES (?, ?, ?)", [org.id, org.value, "pt"],
function(tx, res){
//console.log("Success: " + res.insertId);
},
function(e){
console.log("Error: " + e.message);
});
});
tx.executeSql("SELECT COUNT(*) AS Count FROM tbl_OrgUnit WHERE TYPE = 'pt'", [], function(tx, res){
if(res.rows.length > 0)
console.log("New Port. rows added to tbl_OrgUnit:" + res.rows.item(0).Count);
});
});
}
catch(e)
{
console.log("Error:" + e.message)
}
}
配置:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.Vale.Incident" version="1.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="true" />
<preference name="EnableViewportScale" value="false" />
<preference name="FadeSplashScreen" value="true" />
<preference name="FadeSplashScreenDuration" value=".25" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="GapBetweenPages" value="0" />
<preference name="PageLength" value="0" />
<preference name="PaginationBreakingMode" value="page" />
<preference name="PaginationMode" value="unpaginated" />
<preference name="webviewbounce" value="false" />
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<name>ReportIncident</name>
<description>
Hello World sample application that responds to the deviceready event.
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<preference name="permissions" value="none" />
<preference name="phonegap-version" value="3.5.0" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="blue" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-installLocation" value="auto" />
<preference name="AutoHideSplashScreen" value="false" />
<gap:plugin name="org.apache.cordova.battery-status" />
<gap:plugin name="org.apache.cordova.camera" />
<gap:plugin name="org.apache.cordova.media-capture" />
<gap:plugin name="org.apache.cordova.console" />
<gap:plugin name="org.apache.cordova.contacts" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.device-motion" />
<gap:plugin name="org.apache.cordova.device-orientation" />
<gap:plugin name="org.apache.cordova.dialogs" />
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.file-transfer" />
<gap:plugin name="org.apache.cordova.geolocation" />
<gap:plugin name="org.apache.cordova.globalization" />
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="org.apache.cordova.media" />
<gap:plugin name="org.apache.cordova.network-information" />
<gap:plugin name="org.apache.cordova.splashscreen" />
<gap:plugin name="org.apache.cordova.vibration" />
<!--gap:plugin name="com.millerjames01.sqlite-plugin"-->
<!--plugin name="SQLitePlugin" value="SQLitePlugin" /-->
<icon src="icon.png" />
<icon gap:platform="android" gap:qualifier="ldpi" src="res/icon/android/icon-36-ldpi.png" />
<icon gap:platform="android" gap:qualifier="mdpi" src="res/icon/android/icon-48-mdpi.png" />
<icon gap:platform="android" gap:qualifier="hdpi" src="res/icon/android/icon-72-hdpi.png" />
<icon gap:platform="android" gap:qualifier="xhdpi" src="res/icon/android/icon-96-xhdpi.png" />
<icon gap:platform="blackberry" src="res/icon/blackberry/icon-80.png" />
<icon gap:platform="blackberry" gap:state="hover" src="res/icon/blackberry/icon-80.png" />
<icon gap:platform="ios" height="57" src="res/icon/ios/vale-57.png" width="57" />
<icon gap:platform="ios" height="72" src="res/icon/ios/vale-72.png" width="72" />
<icon gap:platform="ios" height="114" src="res/icon/ios/vale-114.png" width="114" />
<icon gap:platform="ios" height="144" src="res/icon/ios/vale-144.png" width="144" />
<icon gap:platform="webos" src="res/icon/webos/icon-64.png" />
<icon gap:platform="winphone" src="res/icon/windows-phone/icon-48.png" />
<icon gap:platform="winphone" gap:role="background" src="res/icon/windows-phone/icon-173.png" />
<gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="res/screen/android/screen-ldpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="res/screen/android/screen-mdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="res/screen/android/screen-hdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" />
<gap:splash gap:platform="blackberry" src="res/screen/blackberry/screen-225.png" />
<gap:splash gap:platform="ios" height="480" src="res/screen/ios/splash5-320-480.png" width="320" />
<gap:splash gap:platform="ios" height="960" src="res/screen/ios/splash5-320-480.png" width="640" />
<gap:splash gap:platform="ios" height="1136" src="res/screen/ios/splash5-320-480.png" width="640" />
<gap:splash gap:platform="ios" height="1024" src="res/screen/ios/splash5-320-480.png" width="768" />
<gap:splash gap:platform="ios" height="768" src="res/screen/ios/splash5-320-480.png" width="1024" />
<gap:splash gap:platform="winphone" src="res/screen/windows-phone/screen-portrait.jpg" />
<gap:plugin name="org.apache.cordova.statusbar" version="0.1.4" />
<gap:plugin name="nl.x-services.plugins.videocaptureplus" />
<access origin="*" />
<feature name="Camera">
<param name="ios-package" value="CDVCamera" />
</feature>
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
<preference name="CameraUsesGeolocation" value="false" />
<feature name="Vibration">
<param name="ios-package" value="CDVVibration" />
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile" />
<param name="onload" value="true" />
</feature>
<feature name="Capture">
<param name="ios-package" value="CDVCapture" />
</feature>
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection" />
</feature>
<plugin name="Notification" value="CDVNotification" />
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer" />
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile" />
</feature>
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
<feature name="Globalization">
<param name="ios-package" value="CDVGlobalization" />
</feature>
<feature name="Media">
<param name="ios-package" value="CDVSound" />
</feature>
<feature name="Console">
<param name="ios-package" value="CDVLogger" />
</feature>
<feature name="VideoCapturePlus">
<param name="ios-package" value="VideoCapturePlus" />
</feature>
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<feature name="Device">
<param name="ios-package" value="CDVDevice" />
</feature>
<feature name="SQLitePlugin">
<param name="ios-package" value="SQLitePlugin" />
</feature>
<plugin name="SQLitePlugin" value="SQLitePlugin" />
</widget>
问题: 在表格完全加载之前,用户将被重定向到“登录”页面
预期: 只有在数据完全加载后,才会将用户重定向到“登录”页面。到那时,Splash屏幕应该显示给用户。
任何想法如何去做
提前致谢
答案 0 :(得分:0)
在config.xml
添加此行
<preference name="AutoHideSplashScreen" value="false" />
当你想隐藏splashscree时,在你的js中使用这个功能
navigator.splashscreen.hide();