0

我是新的,我看到類似的問題,但很老,沒有解決方案。我想要的只是在activeTab中打開新窗口並保留選項卡組。不幸的是,我的代碼打開新窗口,但不保留標籤,窗口只是全屏。 如果有人能確認我想達到的目標是否可能,我將不勝感激。也許以某種方式意見...再一次它應該爲Android工作。以下是代碼:(鈦手機,Android)activeTab.open()新窗口不保留標籤

// this sets the background color of the master UIView (when there are no windows/tab groups on it) 
Titanium.UI.setBackgroundColor('#000'); 

// create tab group 
var tabGroup = Titanium.UI.createTabGroup(); 

// 
// create base UI tab and root window 
// 
var win1 = Titanium.UI.createWindow({ 
    title:'Tab 1', 
    backgroundColor:'#fff' 
}); 
var tab1 = Titanium.UI.createTab({ 
    icon:'KS_nav_views.png', 
    title:'Tab 1', 
    window:win1 
}); 


// 
// create controls tab and root window 
// 
var win2 = Titanium.UI.createWindow({ 
    title:'Tab 2', 
    backgroundColor:'#fff' 
}); 
var tab2 = Titanium.UI.createTab({ 
    icon:'KS_nav_ui.png', 
    title:'Tab 2', 
    window:win2 
}); 

var label2 = Titanium.UI.createLabel({ 
    color:'#999', 
    text:'I am Window 2', 
    font:{fontSize:20,fontFamily:'Helvetica Neue'}, 
    textAlign:'center', 
    width:'auto' 
}); 

win2.add(label2); 


var data = [ 
    {title:"Sample 1",color:'black',hasChild:true,font:{fontSize:16,fontWeight:'bold'}}, 
    {title:"Sample 2",color:'black',hasChild:true,font:{fontSize:16,fontWeight:'bold'}} 
    ]; 
var table = Titanium.UI.createTableView({ 
    data:data, 
    separatorColor: '#ccc', 
    backgroundColor:'#fff' 
    }); 
win1.add(table); 

// create table view event listener 
table.addEventListener('click', function(e) 
{ 
     var win = Titanium.UI.createWindow({ 
      url:'windows/main.js'  
     }); 

     // this simply opens the new created window but full screen and without original tab group. 

     tabGroup.activeTab.open(win,{animated:true}); 


}); 

// 
// add tabs 
// 
tabGroup.addTab(tab1); 
tabGroup.addTab(tab2); 


// open tab group 
tabGroup.open(); 

回答

0

您必須爲每個選項卡窗口創建導航組。 例如

//Here's the first window... 
var first = Ti.UI.createWindow({ 
    backgroundColor:"#fff", 
    title:"My App" 
}); 

接下來,我們將創建一個NavigationGroup。這是一個控制窗口(參考文檔)的堆棧一個iPhone專用組件 - 我們將通過它我們的第一個窗口,它的最初可見的窗口中使用:

//Here's the nav group that will hold them both... 
    var firstnavGroup = Ti.UI.iPhone.createNavigationGroup({ 
     window:first 
    }); 




    //This is the main window of the application 
    var mainfirst = Ti.UI.createWindow(); 
    mainfirst.add(firstnavGroup); 

然後assing這個mainfirst窗口選項卡。 重複此prosess所有標籤

現在,當你需要打開新的窗口,那麼你必須寫

var second = Ti.UI.createWindow({ 
    background:"#fff", 
    title:"Child Window" 
}); 

    firstnavGroup.open(second); 

我希望這會幫助你。

+0

問題是針對Android,而不是iPhone。 Android沒有導航組 –