0

下面的代碼導致不同的輸出不同的android和ios。下面的myBlob是ios上的{} - 即使在屏幕上繪製後圖像也是空的。在Android中它具有屬性的對象並且工作正常,但iOS圖像始終爲空。鈦ti.paint toimage()在繪製ios後返回{}

這是以前在過去的ios版本和構建,所以我不建設它的權利?我們正在爲鈦SDK使用5.3.0 GA。我已經在TiApp編輯器中爲iOS檢查了模塊。

function uploadImage(signed) { 
    if (signed) { 
     var myBlob; 
     try { 
      myBlob = $.viewPaint.toImage(); 
      var myImage = Titanium.Utils.base64encode(myBlob).toString(); 
      $.nextAction.image = myImage; 
     } catch (ex) { 
      Titanium.API.error('FAILURE HANDLING SIGNATURE DOCUMENT: ' + ex); 
      return; 
     } 
    } 

    $.nextAction.perform(Alloy.Globals.requests); 
} 

鈦塗料模塊爲iPhone

# 
# this is your module manifest and used by Titanium 
# during compilation, packaging, distribution, etc. 
# 
version: 1.4.0 
apiversion: 2 
architectures: armv7 i386 x86_64 arm64 
description: Provides a paint surface user interface view. 
author: Jeff Haynie 
license: Appcelerator Commercial License 
copyright: Copyright (c) 2010-2014 by Appcelerator, Inc. 


# these should not be edited 
name: paint 
moduleid: ti.paint 
guid: 43f13063-d426-4e9c-8a7a-72dc5e4aec57 
platform: iphone 
minsdk: 3.4.1.GA 

在前代碼,增加了執行行動對象

   var route = action.action.uri; 
       Ti.API.info('route = ' + route); 
       newAction.execute = function(requestManager) { 
        Titanium.App.fireEvent('app:index:view:requested', 
         controller : 'signscreen', 
         uri : route 
        }); 
       }; 

代碼觸發該事件打開:

  Titanium.App.fireEvent('app:index:view:requested', { 
       controller : 'signature' 
      }); 

回答

0

,如果你有在你的覆蓋你的paintview視圖層次的內容,如一個確認對話框或關閉在導航控制器的視圖,而不是窗口關閉paintview總是返回空之前,抓住你的paintview。 android將繼續正常工作,但ios不會因爲視圖不存在於視圖層次結構中。

+0

ahhhh,謝謝....那是一個createAlertDialog! – user6701009

0

你控制檯日誌值爲{}是紅鯡魚。

測試上:

  • TiSDK 5.2.2.GA,5.3.0.GA
  • ti.paint:1.4.0,1.4.1(我們與修正版本已被忽略APPC )
  • 隨着<run-on-main-thread>false</run-on-main-thread>在tiapp.xml

使用例如從模塊app.js和加入如下:

var buttonSave = Ti.UI.createButton({ bottom:100, right:10, width:75, height:30, title:'Save' }); 
buttonSave.addEventListener('click', function(e){ 
    var test = paintView.toImage(); 
    console.log(test.length); 
    console.log(paintView.toImage()); 
    var imageFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,"testing.png"); 
    imageFile.write(paintView.toImage()); 
}); 
win.add(buttonSave) 

你會發現,

  1. 記錄的值始終將{}
  2. 您分配toImage(物體的長度),以增加你添加像素到您的paintView
  3. 圖像被打寫到一個文件。
+0

你還會發現'test'有寬度('test.width')和高度('test.height') – StephenFeather

+0

好吧。所以我一定是做錯了,因爲長度總是相同的,並且base 64總是空白的? – user6701009

+0

[INFO] 14162對於test.length,即使在屏幕上繪圖時也是如此。圖像始終是空白的。 – user6701009