Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28443] iOS: ScrollView setZoomScale()/setContentOffset() methods crash as of 10.0.0

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2021-05-10T19:32:28.000+0000
Affected Version/sRelease 10.0.0
Fix Version/sRelease 10.0.0
ComponentsiOS
LabelsScrollView, contentOffset, ios, regression, zoom
ReporterHans Knöchel
AssigneeJoshua Quick
Created2021-05-07T20:27:35.000+0000
Updated2021-05-10T19:32:28.000+0000

Description

See the following test case:
var win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});

var scrollView = Ti.UI.createScrollView({
    contentWidth: 'auto',
	contentHeight: 'auto',
	top: 0,
	bottom: 0,
	backgroundColor: 'black',
	showVerticalScrollIndicator: false,
	showHorizontalScrollIndicator: false,
	maxZoomScale: 3,
	minZoomScale: 1,
	zoomScale: 1,
	disableBounce: true

});
var content = Ti.UI.createImageView({ image: Ti.UI.createView({ width: 100, height: 100, backgroundColor: 'red', zoomScale: 1 }).toImage() });

scrollView.addEventListener('doubletap', () => {
    console.warn('Zoom!')
	scrollView.setZoomScale((scrollView.zoomScale === 1) ? 2 : 1, {
		animated: true
	});
});

scrollView.add(content);
win.add(scrollView);
win.open();
Works fine on SDK 9.3.2, throws an error and does not work on SDK 10:
[ERROR] /app.js:23
[ERROR]   scrollView.setZoomScale(scrollView.zoomScale === 1 ? 2 : 1, {
[ERROR]                           ^
[ERROR] TypeError: scrollView.setZoomScale is not a function. (In 'scrollView.setZoomScale(scrollView.zoomScale === 1 ? 2 : 1, {
[ERROR]     animated: true })', 'scrollView.setZoomScale' is undefined)

Comments

  1. Joshua Quick 2021-05-08

    The ScrollView.setContentOffset() method is busted too. This looks like a negative consequence of our remove of getter/setter methods. I'll need to double check how we kept WebView.setHtml() support on iOS and do the same on ScrollView.
  2. Joshua Quick 2021-05-08

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12788
  3. Christopher Williams 2021-05-10

    merged to master and 10_0_X

JSON Source