[TIMOB-17692] iOS: Cannot load saved images anymore
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2014-09-26T20:15:08.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 3.4.0, Release 3.5.0 |
| Components | iOS |
| Labels | TCSupportTriage, regression |
| Reporter | Jérôme Danthinne |
| Assignee | Jon Alter |
| Created | 2014-09-10T12:45:10.000+0000 |
| Updated | 2014-11-21T20:26:09.000+0000 |
Description
This was working fine with SDK 3.3.0, but since 3.4.0-beta, my app cannot load previously saved images anymore...
message = "invalid image type";
[ERROR] : nativeLocation = "-[TiUIImageView setImage_:] (TiUIImageView.m:685)";
[ERROR] : nativeReason = "expected TiBlob, String, TiFile, was: TiBlob";
Strangely, it seems to expect a TiBlob, and gets one, but doesn't load it...
Thank you for the report. Can you please provide a test case?
Here's a very small part of my app, causing the bug. First pick an image, then click "Show Image" to load it.
var imageFilename = "test.jpg"; function PickImage() { Ti.Media.openPhotoGallery({ mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO], success: function(event) { var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename); if (f.exists()) { f.deleteFile(); f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename); } f.write(event.media); } }); } function ShowImage() { var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename); if (f.exists()) { var imageBlob = f.read(); $.imageView.image = imageBlob; } } $.index.open();Possibly related to TIMOB-16882.
PR master: https://github.com/appcelerator/titanium_mobile/pull/6083 PR 3_4_X: https://github.com/appcelerator/titanium_mobile/pull/6084
Steps to Test
1. Click "Pick Image" 2. Select a photo 3. Click "Show Image" 4. The image should now be visible at the bottom of the screen.Test Code
var win = Ti.UI.createWindow({ backgroundColor: 'white' }); win.open(); var button1 = Ti.UI.createButton({ title: 'Pick Image', top: 50, height: 50 }); button1.addEventListener('click', function() { PickImage(); }); win.add(button1); var button2 = Ti.UI.createButton({ title: 'Show Image', top: 150, height: 50 }); button2.addEventListener('click', function() { ShowImage(); }); win.add(button2); var imageView = Ti.UI.createImageView({ width:Ti.UI.FILL, height:300, bottom: 0, backgroundColor: 'blue' }); win.add(imageView); var imageFilename = "test.jpg"; function PickImage() { Ti.Media.openPhotoGallery({ mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO], success: function(event) { var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename); if (f.exists()) { f.deleteFile(); f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename); } f.write(event.media); } }); } function ShowImage() { var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename); if (f.exists()) { var imageBlob = f.read(); imageView.image = imageBlob; } else { console.log("image does not exist"); } }Verified fix on: Mac OSX 10.9.4 Appcelerator Studio, build: 3.4.0.201409131030 Titanium SDK build: 3.4.0.v20140916151649 Titanium CLI, build: 3.4.0-rc4 Alloy: 1.5.0-rc2 Xcode6 GM Seed iPhone Device 5 (8.0 GM Seed) Used the above test code and built to device. The image was shown on the screen after I selected it and clicked 'Show Image'. Closing ticket.