【问题标题】:Titanium TabGroup: How to close window and then display the tab Group?Titanium TabGroup:如何关闭窗口然后显示选项卡组?
【发布时间】:2012-03-26 14:11:27
【问题描述】:

我有以下应用流程:

第一个屏幕是登录屏幕,如果登录成功,选项卡组就会打开。

这里是代码:

app.js

var win = Titanium.UI.createWindow
({
    title:'User Login',
    url:'Login.js',
    tabBarHidden:true,
    backgroundColor:'gray',
    navBarHidden:false
});
win.open();

Login.js

var win = Ti.UI.currentWindow;

// some UI controls

loginBtn.addEventListener('click', function(e)
{
   //calling web service     
   if(isSuccess == 1)
   {
       var tabGroup = Titanium.UI.createTabGroup();    
       // code to create Tab 
       tabGroup.open();   
   }
}

现在,如果我隐藏 currentWindow (win) 一切正常但登录视图始终显示在后台!所以我想关闭登录窗口,然后打开选项卡组。所以我尝试了:

win.close();
tabGroup.open();

但不起作用的应用程序崩溃了。

那么,如何关闭窗口然后显示选项卡组???

谢谢....

【问题讨论】:

    标签: titanium appcelerator titanium-mobile


    【解决方案1】:

    解决了!!!正如 slash197 在 Login.js 中所建议的那样,我试图关闭作为根窗口的win。所以我在 Login.js 中使用了一个虚拟窗口并关闭它并打开 tabGroup 。喜欢:

    Login.js

    var win = Ti.UI.currentWindow;
    var loginView = Ti.UI.createWindow
    ({
        backgroundColor:'transparent'
    });
    

    并将所有 UI 组件添加到 loginView 而不是 win

    那么对于 Android

    loginView.open();
    

    对于 iPhone

    loginView.open();
    win.add(loginView);
    

    成功后:-

    loginBtn.addEventListener('click', function(e)
    {
       //calling web service     
       if(isSuccess == 1)
       {
           var tabGroup = Titanium.UI.createTabGroup();    
           // code to create Tab 
    
           //for Android
           loginView.close();
    
           //for iPhone
           win.remove(loginView);
    
           tabGroup.open();   
       }
    }
    

    注意:-不确定这是最好的方法。但它对我有用。

    【讨论】:

      【解决方案2】:

      如果该窗口是第一个而不是根元素并且不能关闭。您可以尝试删除它的所有孩子并将其背景设置为透明,然后打开您的tabGroup

      【讨论】:

      • @adrian aproape de tine, Targu Mures
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-30
      • 2020-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多