Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Custom Navigation Controller, compatible with Android and iPhone
// Flags, is this for Android or iPhone?
var iPhone = false;
var Android = false;
if(Ti.Platform.osname == 'iphone'){
iPhone = true
};
if(Ti.Platform.osname == 'android'){
Android = true
};
// our navigation function, to be compatible with both platforms
function NavigationController(a){
// this is to avoid errors
a = a || {};
a.window = a.window || Ti.UI.createWindow();
// this is to handle the iPhone Nav functionality
if(iPhone){
var win = Ti.UI.createWindow();
var nav = Ti.UI.iPhone.createNavigationGroup({
window: a.window
});
win.add(nav);
win.push = function(b){
nav.open(b);
};
return win;
}
// there is no Nav in Android, so let's return the window
if(Android){
a.window.push = function(b){
b.open({
fullscreen:false
});
}
return a.window;
}
}
// start the app right here
var win = Ti.UI.createWindow({
backgroundColor:'green'
});
var btn = Ti.UI.createButton({
title:'push next window to the stack',
width:300,
height:50
});
win.add(btn);
// let's call our custom navigation function
var navigation = NavigationController({
window:win
});
// open it
navigation.open();
// example of how to push (or open) the next window
btn.addEventListener('click', function(){
var win2 = Ti.UI.createWindow({
backgroundColor:'red'
});
navigation.push(win2);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.