本文介绍了收到一个内存警告iOS后使用相机与科尔多瓦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我拍照时,我开始不断收到记忆警告。我使用Cordova 3.5和相机插件与这些设置。

When I take a photo, I begin to receive memory warnings continuously. I'm using Cordova 3.5 and the camera plugin with these settings.

var _config;      
var pictureSource;
var destinationType; // sets the format of returned value.
var encodingType; // enconding type 0=JPG 1=PNG

/**
 * Initialize camera plugin.
 * @param {object} config - settings.
 */
function initialize(config) {
    alert("CAMERA is comming!!");
    // Wait for Cordova to connect with the device
    document.addEventListener('deviceready', onDeviceReady, false);
}

/** 
 * Cordova is ready to be used!
 * @param {object} config - settings.
 */
function onDeviceReady() {

    console.log("CAMERA is READY!!");
    pictureSource=navigator.camera.PictureSourceType;
    destinationType=navigator.camera.DestinationType;
    encodingType = navigator.camera.EncodingType;
    capturePhoto();
}

/**
 * Set camera plugin settings.
 * @param {object} config - settings.
 */
function setConfig(config) {
    _config = config;
}

/**
 * Take picture using device camera and retrieve image as base64-encoded string.
 */
function capturePhoto() {
    setConfig({ quality: 20, destinationType: destinationType.DATA_URL, encodingType: 0});
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, _config);
}

/**
 * Photo is successfully retrieved.
 * @callback getPicture~onPhotoDataSuccess
 * @param {string} imageData - A base64-encoded image.
 */
function onPhotoDataSuccess(imageData) {
    //Edit photo
}   

$ b

感谢您的帮助!

推荐答案

最后,我通过修复照片大小解决了这个问题:

Finally, I solved the problem by fixing the photo size:

 /**
 * Take a picture and get the image as base64-encoded string.
 */
function capturePhoto() {
    setConfig({ quality: 20, targetWidth: 600, targetHeight: 600, correctOrientation: true, destinationType: destinationType.DATA_URL, encodingType: 0});
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, _config);
}

这篇关于收到一个内存警告iOS后使用相机与科尔多瓦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 01:39