Feature
The "canScale" property exists on Android, but not on iOS. It lets you pinch around an image.
Workaround
On iOS, you can dump the image in a scroll view. But it takes quite a bit more code to get it to work properly.
Sample Code
The following shows a large remote image (~500kb). It may take a moment for the sample to come up. Feel free to download the image locally to speed it up. It demonstrates the Android and iOS approaches to a scalable image.
var win = Ti.UI.createWindow({ backgroundColor: '#000' });
var image = Ti.UI.createImageView({
image: 'http://appc.me/content/appceleratorHat.jpg',
width: 'auto', height: 'auto', canScale: true
});
if (Ti.Android) {
// this simple code works in Android
win.add(image);
}
else {
// but iOS requires all of this
var scroll = Ti.UI.createScrollView({
contentHeight: 'auto', contentWidth: 'auto',
maxZoomScale: 1, minZoomScale: 0.16
});
image.addEventListener('load', function() {
scroll.zoomScale = 0.16;
});
scroll.add(image);
win.add(scroll);
}
win.open();
Associated Helpdesk Ticket
http://appc.me/APP-121155 http://appc.me/APP-422217 http://appc.me/APP-768251
The native iOS doesn't have a 'canScale' property in UIImageView, and implementing this would have a significant performance and memory hit for *any* image view as we'd be manually stuffing it into the scroll view, even *if* canScroll was false.
Pull request for this functionality was sent in by Dohko from the community: https://github.com/appcelerator/titanium_mobile/pull/426/files
Need to re-evaluate.
Rejecting request now with the text: The canScale property is that, in Android, you can zoom and pan an image within its view. To have something similar, it'd require embedding a UIScrollView into the view hierarchy of each image view, which is incredibly expensive. This code appears to instead disable the proper scaling of the image inside its view, meaning it will ignore the size specified by the view, which is NOT what canScale is meant to do.
Implementing such would be rather expensive performance-wise on each image view, and may lead to other regressions (IE, an imageview with canscale would be unpredictable within a table view)
Closing as duplicate.