Skip to content

Instantly share code, notes, and snippets.

@pec1985
Created July 22, 2011 23:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pec1985/1100699 to your computer and use it in GitHub Desktop.
Save pec1985/1100699 to your computer and use it in GitHub Desktop.
Scroll to position - iOS - Appcelerator
var win = Ti.UI.createWindow({
title:'Row #50'
});
var buttonBar = Ti.UI.createButtonBar({
labels:['top','middle','bottom']
});
win.rightNavButton = buttonBar;
var tableData = [];
for(var i = 0; i < 100; i++){
tableData.push(
{title:'Row #'+i}
);
}
var table = Ti.UI.createTableView({
data:tableData
});
win.add(table);
win.open({modal:true});
buttonBar.addEventListener('click', function(e){
switch(e.index){
case 0:
table.scrollToIndex(50,{position:Titanium.UI.iPhone.TableViewScrollPosition.TOP});
break;
case 1:
table.scrollToIndex(50,{position:Titanium.UI.iPhone.TableViewScrollPosition.MIDDLE});
break;
case 2:
table.scrollToIndex(50,{position:Titanium.UI.iPhone.TableViewScrollPosition.BOTTOM});
break;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment