Question

For an iPad Application developed using Appcelerator Titanium SDK 3.1.2, I have a Ti.UI.Tab Group which contains 5 Ti.UI.Tabs. Each Tab contains a Root Ti.UI.Window and certain tabs open additional windows when relevant.

When you double tap any of the Tabs in the Tab Group, the Tab double tapped will reset its content to the Root Window, automatically closing windows inside it that were open.

I want to disable this from happening, but there is no property for either the Tab Group or the Tab itself that allows me to prevent the double tap from occurring.

Était-ce utile?

La solution 2

I encountered a similar problem before.

End up I compose my own tab bar to do the tab switching. So that whenever a tab button is clicked, I can get the tab event and do the checking.

Hope it helps.

Autres conseils

An alternative to creating your own TabGroup Control using Views, is to add a NavigationGroup Control inside the Tab where you want to prevent resetting of Windows when a double tap occurs on the Tab.

In your Tab Control for your TabGroup, create an empty Window Control and link it to your Tab as you would normally do. Then, create a NavigationGroup Control and add it to the Tab's root Window:

//Set up your Tab Group with a Tab and a Root Window for the Tab
var tabGroup = Ti.UI.createTabGroup();

var tabWin = Ti.UI.createWindow({
    navBarHidden:true
});

var tab = Ti.UI.createTab({
    window:tabWin
});
tabGroup.addTab(tab);

//Create a Root Window Control for the Navigation Group
var navWin = Ti.UI.createWindow({
    title:'NavGroup Root Window'
}); 

//Create a NavigationGroup Control and add it to the Root Window
var nav = Ti.UI.iPhone.createNavigationGroup({
    window: navWin
});
tabWin.add(nav);

//Launch Tab Group
tabGroup.open();

When you open Windows inside this tab, instead of using the Tab.open(Window) method, use the NavigationGroup.open(Window). Let the NavigationGroup manage the Window Stack instead of the Tab:

//Open a new Window inside the Navigation Group
var win1 = Ti.UI.createWindow();
nav.open(win1);

//Close this Window you opened
nav.close(win1);

By doing this, you prevent the Window Stack from resetting when users double tab the relevant Tab that contains the NavigationGroup Object.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top