New Feature / Parity Issue
Android has a "scrollToBottom()" method that iOS does not have. It's a common interaction, so I think it's a good idea to add it to iOS as well.
Opened an APIDoc ticket for this as well: [TIDOC-538]
What It Does
Scrolls to the bottom. For horizontal scroll views, this means the rightmost point of the scroll view.
Signature
var scroll = Ti.UI.createScrollView();
/* no ret val */ scroll.scrollToBottom();
Example
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var scroll = Ti.UI.createScrollView({
contentHeight: '2000',
scrollType: 'vertical'
});
scroll.add(Ti.UI.createLabel({
text: 'Welcome to the top! Touch anywhere to scroll to bottom.', textAlign: 'center',
color: '#000',
width: Ti.UI.SIZE, height: Ti.UI.SIZE,
top: 0
}));
scroll.add(Ti.UI.createLabel({
text: 'Welcome to the bottom!', textAlign: 'center',
color: '#000',
width: Ti.UI.SIZE, height: Ti.UI.SIZE,
bottom: 0
}));
scroll.addEventListener('click', function (evt) {
if (!scroll.scrollToBottom) {
alert('Whoops! scrollToBottom() does not exist on this platform.');
}
else {
scroll.scrollToBottom();
}
});
win.add(scroll);
win.open();
Updated Test case to include more type of scrollviews and scrollToBottom behavior.
[Pull pending](https://github.com/appcelerator/titanium_mobile/pull/2145)
Pull merged.
Closing issue Tested with Ti Studio build 2.1.0.201206111802 Ti Mobile SDK 2.1.0.v20120612102301 hash refeef019 OSX Lion 10.7.3 iPhone 4S OS 5.1 Pressing the scroll view scrolls the view to the bottom
anvil test case added PR Link: https://github.com/appcelerator/titanium_mobile/pull/4958