2013-10-25 50 views
0

我目前正在研究下面的代碼,下面的代碼是鈦導航組中的ios導航組。我試圖讓它或者既有ios又有android,但看起來很複雜。我怎樣才能使它爲iOS和Android。titanium導航組爲ios和android

var win1 = Titanium.UI.createWindow(); 



     var win2 = Titanium.UI.createWindow({ 

      backgroundColor: 'white', 

      barColor: '#336699' 

     }); 



     var win3 = Titanium.UI.createWindow({ 

      backgroundColor: 'white', 

      barColor: '#336699', 

      title: 'Register' 

     }); 



     var win4 = Titanium.UI.createWindow({ 

      backgroundColor: 'white', 

      barColor: '#336699', 

      title: 'Sign in' 

     }); 





     //create view1 

     var view1 = Titanium.UI.createView(); 



     //create label1 

     var label1 = Titanium.UI.createLabel({ 

     text: 'Welcome', 

     height: 40, 

     width: 250, 

     top: 100, 

     color: '#336699' 

     }); 





     //create button1 

     var button1 = Titanium.UI.createButton({ 

      title: 'Register', 

      height: 35, 

      width: 100, 

      top: 210 

     }); 



     button1.addEventListener('click', function(){ 

      nav.open(win3); 

     }); 



     var nav = Titanium.UI.iPhone.createNavigationGroup({ 

      window: win2 

     }); 





     //create view2 

     var view2 = Titanium.UI.createView(); 



     //create label2 

     var label2 = Titanium.UI.createLabel({ 


     height: 45, 

     width: 200, 

     top: 145, 

     color: '#336699' 

     }); 





     //create button2 

     var button2 = Titanium.UI.createButton({ 

      title: 'Sign in', 

      height: 35, 

      width: 100, 

      top: 250 

     }); 



     button2.addEventListener('click', function(){ 

      nav.open(win4, {animated:true}); 

     }); 



     var nav = Titanium.UI.iPhone.createNavigationGroup({ 

      window: win2 

     }); 







     view2.add(button1); 

     view1.add(label1); 

     win2.add(view1); 



     view2.add(button2); 

     view2.add(label2); 

     win2.add(view2); 



     win1.add(nav); 

     win1.open(); 
+0

http://stackoverflow.com/questions/12530946/navigationgroup-android-in-titanium –

回答

0

在Git上有幾個模塊用於跨平臺NavigationGroups,如https://github.com/ricardoalcocer/TiCrossPlatformNavigationGroup

你也可以在Git上搜索「Titanium Navigation」,還有更多的東西,看看你的需求是什麼。我沒有親自使用過其中的一個,所以這不是一個建議。

除此之外,請注意NavigationGroups是已棄用與最新的Titanium SDK,不會在3.2.0。因此請務必使用NavigationWindows