NavigationGroup钛的android [英] NavigationGroup android in Titanium
问题描述
林新的钛,允许开发者创建跨平台的应用程序你好。我需要创建与Android和iOS的作品导航组。有没有明确的解决方案(如Ti.UI.iPhone.createNavigationGrou()只适用于iPhone,
Hi Im new to titanium which allow developer to create cross platform apps. I need to create a navigation group that works with both android and iOS. is there any clear solution ( as Ti.UI.iPhone.createNavigationGrou() only works on iphone,
感谢您
推荐答案
我有以下NavigationController,生活在Android和iPhone的文件夹:
I have the following NavigationController that lives in the android and iphone folders:
机器人
var NavigationController = function() {
var self = this;
self.open = function(windowToOpen) {
//make "heavyweight" and associate with an Android activity
windowToOpen.navBarHidden = windowToOpen.navBarHidden || false;
if(!self.rootWindow) {
windowToOpen.exitOnClose = true;
self.rootWindow = windowToOpen;
}
windowToOpen.open();
};
self.close = function(windowToClose) {
windowToClose.close();
};
return self;
};
module.exports = NavigationController;
iphone
var NavigationController = function() {
var self = this;
function createNavGroup(windowToOpen) {
self.navGroup = Ti.UI.iPhone.createNavigationGroup({
window : windowToOpen
});
var containerWindow = Ti.UI.createWindow();
containerWindow.add(self.navGroup);
containerWindow.open();
};
self.open = function(windowToOpen) {
if(!self.navGroup) {
createNavGroup(windowToOpen);
}
else {
self.navGroup.open(windowToOpen);
}
};
self.close = function(windowToClose) {
if(self.navGroup) {
self.navGroup.close(windowToClose);
}
};
return self;
};
module.exports = NavigationController;
然后,你可以用它(你会自动获得正确的基础上运行时):
Then, you can just use it (you will automatically get the correct one based on your runtime):
var NavigationController = require('NavigationController')
var MyView = require("ui/MyView");
var controller = new NavigationController();
var myView = new MyView(controller);
controller.open(myView);
您可以继续打开窗户,他们进入堆叠。请注意,我通过控制器进入第一种观点。你一直这样做:
You can continue opening windows and they go on the stack. Notice I passed the controller into the first view. You keep doing that:
controller.open(new SecondView(controller));
在返回
按钮会自动推东西了你的筹码。如果您需要以编程方式做到这一点,只是告诉控制器将其关闭:
The back
button will automatically push things off your stack. If you need to do it programatically, just tell the controller to close it:
controller.close(myView);
这篇关于NavigationGroup钛的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!