Created
December 14, 2011 21:54
-
-
Save mauropm/1478739 to your computer and use it in GitHub Desktop.
Example NS and dynamic creation of views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tt.ui.createStackView = function(_args) { | |
var stack = Ti.UI.createView(tt.combine($$.stretch,_args.props||{})); | |
stack.currentIndex = _args.currentIndex||0; | |
//populate stack | |
for (var i = 0; i < _args.views.length; i++) { | |
var w = _args.views[i]; | |
if (i == stack.currentIndex) { | |
w.visible = true; | |
} | |
else { | |
w.visible = false; | |
} | |
stack.add(w); | |
} | |
stack.addEventListener('changeIndex', function(e) { | |
for (var j = 0;j < _args.views.length;j++) { | |
if (j == e.idx) { | |
_args.views[j].visible = true; | |
stack.currentIndex = j; | |
} | |
else { | |
_args.views[j].visible = false; | |
} | |
} | |
}); | |
return stack; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment