简体   繁体   English

使用jQuery和PhoneGap在Android中无法显示图像,但在iPhone中可以使用

[英]Image not displaying in Android using jQuery and PhoneGap but same works in iPhone

It took me for the whole day to figure out this problem. 我花了一整天的时间来解决这个问题。 I am working on a webapp (using Phonegap + HTML + jQuery + CSS). 我正在使用webapp(使用Phonegap + HTML + jQuery + CSS)。 It consists of one screen, which displays user signatures. 它由一个屏幕组成,该屏幕显示用户签名。 I used the same .js file which is used in iPhone and in that the signature image is appearing without any problem, but the same code is not working on Android (I tried using Android 2.2.1, 2.3.3, 3.0 and 4.0) But nothing works. 我使用了与iPhone中相同的.js文件,并且签名图像似乎没有出现任何问题,但是相同的代码在Android上不起作用(我尝试使用Android 2.2.1、2.3.3、3.0和4.0)但是什么都行不通。 Following is the code snippet from my .js file : 以下是我的.js文件中的代码段:

SignatureButtonThumbComponent.prototype.setInitialValue = function () {
       var date, value;
       value = this.record.valueForField(this.config.key);
       //value = window.btoa(this.record.valueForField(this.config.key)); // Not Working
       console.log("Signature Value :  " + value);
       console.log("Signature Date value : " + date);
       date = this.record.valueForField(this.config.key_date);
       if (value !== 'undefined') {
          this.el.append("<button class='captured_signature_button'><img src='" + value + "'/></button>");
        if (date) {
             return this.el.append("<div class='signature_date'>" + (Formatter.timeFormattedNicely(date)) + "</div>");
                    }
                } else {
                    return this.el.append("<button class='big blue arrow_button' id='get_patient_signature'><span>" + this.config.button_label + "</span><span class='icons arrow_right'></span></button>");
                }
            };

EDIT: Following is my logcat output : 编辑:以下是我的logcat输出:

09-21 12:01:19.562: D/PhoneGapLog(1362): Signature Date value : undefined
09-21 12:01:19.672: D/PhoneGapLog(1362): Signature Value :  undefined

After Figuring little more, What Now I am getting in logcat is this : 09-21 16:33:27.947: D/PhoneGapLog(948): file:///android_asset/www/new_mobile.js: Line 15790 : Signature Value : data:, 经过09-21 16:33:27.947: D/PhoneGapLog(948): file:///android_asset/www/new_mobile.js: Line 15790 : Signature Value : data:,之后,我现在在logcat中得到的是: 09-21 16:33:27.947: D/PhoneGapLog(948): file:///android_asset/www/new_mobile.js: Line 15790 : Signature Value : data:,

Finally after the whole day's run, I found the solution. 经过一整天的运行,终于找到了解决方案。 Basically Android does not support canvas of HTML5, though it claims for the same. 基本上,Android声称它也支持HTML5 canvas Whenever I tried to save paint of canvas object, I got data:, meaning null as an output. 每当我尝试保存canvas对象的绘画时,我都会得到data:,这意味着将null作为输出。 Here is a nice js, which you can use to override the default method of canvas.toDataURL() . 这是一个不错的js,您可以使用它来覆盖canvas.toDataURL()的默认方法。 The only drawback to this js is that its comparatively slow to save your graphic. 该js的唯一缺点是保存图形的速度相对较慢。 But as of my situation, its well suited and I integrated it in my jquery. 但就我的情况而言,它非常适合,我将其集成到了jquery中。 You can find this js here : http://code.google.com/p/todataurl-png-js/ 您可以在以下位置找到此js: http : //code.google.com/p/todataurl-png-js/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Phonegap相机,可以在Android上使用,在iPhone上什么也没有 - Phonegap camera, works on Android, nothing happens on iPhone 使用phonegap / jquery for android显示来自外部URL的图像 - Display an image from external url using phonegap/jquery for android 使用PhoneGap以HTML显示联系人图像 - Displaying contact image in HTML using PhoneGap 无法在iPhone App上使用PhoneGap和javascript获取JSON结果,但在Android app上使用相同的代码获取结果 - Cannot get JSON results using PhoneGap and javascript on iPhone App but get results on android app using same code 使用phonegap的iphone和android中的闹钟应用程序 - Alarm clock application in iphone and android using phonegap Xcode iPhone应用程序使用PhoneGap到Android应用程序 - Xcode iPhone app to Android app using PhoneGap 使用PhoneGap在Android和iPhone上进行“ touchmove”事件 - “touchmove” event on Android &iPhone using PhoneGap 带有jQuery的Phonegap更改图像src在Android上不起作用 - Phonegap change image src with jquery not working on Android SVG图像无法在android phonegap项目中的div中正确显示 - SVG image not displaying correctly inside a div in android phonegap project 带有Jquery mobile的android 4.0.3中的Phonegap应用程序未显示内容 - Phonegap application in android 4.0.3 with Jquery mobile is not displaying content
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM