1
我想要構建一個可將圖片旋轉90度的鈦應用程序。我的視圖顯示了imageView和我想用來旋轉按鈕的按鈕。但我總是得到'未定義'的錯誤。見我的代碼和日誌如下:將圖片旋轉90°
var image;
var imageSet = false;
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, "savedChallengeImage.jpeg");
if(file) {
$.picture.setImage(file);
image = file;
imageSet = true;
}
function rotate() {
if (imageSet) {
var t = Titanium.UI.create2DMatrix();
var spin = Titanium.UI.createAnimation();
t = t.rotate(90);
spin.transform = t;
file.animate(spin);
}
}
編輯:我已經修改了文件對象的圖像對象,但它以同樣的方式表現。我是否正確地獲取圖像對象?
image = $.picture.getImage();
image.animate(spin);
而且我的日誌:
[ERROR] : Script Error {
[ERROR] : backtrace = "#0() at :0";
[ERROR] : line = 17;
[ERROR] : message = "'undefined' is not a function (evaluating 'file.animate(spin)')";
[ERROR] : name = TypeError;
[ERROR] : sourceId = 319168864;
[ERROR] : sourceURL = "file:///Users/rellerkmann/Library/Developer/CoreSimulator/Devices/97B059B3-D010-402B-834F-E2647DC8BBC9/data/Containers/Bundle/Application/BB7A6057-D27E-4AB3-92AB-051BE30087BE/RegApp.app/alloy/controllers/challengePicturePage.js";
[ERROR] : }
這種變化並沒有改善的事情。請看看我更新的問題。 – 2014-10-07 13:49:05
當您使用getImage()時,您將再次返回一個File對象。你有沒有試過$ .picture.animate? – STT 2014-10-07 14:17:19
謝謝你,這個伎倆。 – 2014-10-07 14:23:53