我第一次尝试使用Cordova本机插件.我开始使用相机和文档中提供的示例代码.然而,这是失败的,并且navigator.camera未定义.
我已经包含了下面的代码.
<div data-role="page" id="CameraPage">
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for device API libraries to load
//
document.addEventListener("deviceready",onDeviceReady,false);
// device APIs are available
//
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageData) {
alert("Photo Data Success");
// Uncomment to view the base64-encoded image data
// console.log(imageData);
// Get image handle
//
var smallImage = document.getElementById('smallImage'); …Run Code Online (Sandbox Code Playgroud) 尝试将我的PhoneGap javascript代码移植到Xcode中以便在iOS中进行调试.使用Cordova-3.0.0.
我打电话的时候:
navigator.connection.type
Run Code Online (Sandbox Code Playgroud)
我正在为navigator.connection获取一个'undefined'.
我没有在config.xml中正确包含网络连接插件,还是有其他不妥之处?是的,我包含了专门针对iOS的正确cordova.js文件.是的,设备已经被解雇了.
更新:我目前只在iOS模拟器上运行它.
我的config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.test" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Hello Cordova</name>
<description>
Description
</description>
<author email="dev@callback.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<plugins>
<plugin name="NetworkStatus" value="CDVConnection" />
</plugins>
</widget>
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!