Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2551] iOS: Using tabGroup.setActiveTab to switch to a tab in "More..." fails to initialize window

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-07-23T21:03:11.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2013 Sprint 15 API, 2013 Sprint 15, Release 3.2.0
ComponentsiOS
Labelsapi, module_tabgroup, qe-testadded, supportTeam
Reporterwallneradam
AssigneeVishal Duggal
Created2011-04-15T03:22:33.000+0000
Updated2014-10-20T22:31:40.000+0000

Description

Problem

There is a bug with tabGroup. When I want to switch to a tab under the "More..." tab with tabGroup.setActiveTab, the content of the window is not initialized. If I first click to More then try to switch with setActiveTab it works good.

Small snippet

An example. Click the last button.

var tg = Ti.UI.createTabGroup();
var fw = null;
for (var i=0; i<9; i++) {
    var f = function(i) {
        var w = Ti.UI.createWindow({
            title: 'Tab ' + i,
            backgroundColor: '#fff'
        });
        var t = Ti.UI.createTab({
            title: w.title,
            window: w,
            icon:'KS_nav_ui.png'
        });

        if (i > 0) {
            var l = Ti.UI.createLabel({
                text: w.title + ' Label'
            });
            w.add(l);

            var btn = Ti.UI.createButton({
                top: i*40 - 20, height: 35,
                left: 100, width: 120,
                title: 'Jump to Tab ' + i
            });

            btn.addEventListener('click', function(e) {
                tg.setActiveTab(t);
            });

            fw.add(btn);

        } else {
            fw = w;
        }

        tg.addTab(t);
    }(i);
}

tg.open();

Additional details

All Titanium version is affected. I've tried this with the latest version from git as well. (With the latest Ti from git some tab has no title randomly, but it is another bug I think)

Associated thread

http://developer.appcelerator.com/question/128978/how-i-can-set-active-tab-if-tabgroup-have-more-than-5-tabs

Comments

  1. wallneradam 2011-04-15

    *EDIT BY STEVE:* Code removed. Developer who implements this feature should not look at or use this code due to possible rights issues.
  2. Opie Cyrus 2011-04-15

    FYI - Unable to reproduce with 2.2 API's on Android with latest pull of 1.5.1 from master @ 12/11/2010 1:10AM CST.

  3. Eduardo Gomez 2011-08-09

    Associated HD ticket

    PRO customer relying on this, http://appc.me/c/APP-717823

    Target environment

    {noformat} Product: Mobile SDK - Mobile 1.7.1 Platform OS: iOS - Version 4.2 {noformat}

    Tested on

    Emulator iOS 4.x

    Problem

    Similar issue encountered where customer want to switch to a tab under the "More..." tab with contents of the window is not properly loaded. Window inside the MoreTab has no view inside [image](http://imageshack.us/photo/my-images/593/windowinmore.png/). Usual view of that window [image](http://imageshack.us/photo/my-images/40/normalwindow.png/). Once the number of tabs have decreased [image](http://imageshack.us/photo/my-images/641/windowwomore.png/).
  4. Oliver Rowlands 2011-09-09

    FYI: Just encountered the same problem with the continuous builds (1.7.3.v20110826161351). @wallneradam's solution solved my problem.
  5. Michael McDonald 2011-09-14

    I encountered the same problem with build 1.7.2.97c3689. @wallneradam's solution worked for me. I imagine that when initializing windows and UI elements within 'More' Tabs, Titanium is looking up the chain of windows for initialization information and the 'More' part of that chain is incomplete.
  6. Remko Posthuma 2011-12-11

    Hello Appcelerator Team, Please implement Wallneradam solution in the upcoming releases. The behavior of the setActiveTab with more then 5 tab groups is a bug and the solution is in this post, so why wait to implement this? Now I need to implement it myself every time a new version is published.
  7. Don Thorp 2011-12-11

    @Remko we cannot use code added to a JIRA. If you'd like to submit this as a patch then please sign our CLA and submit a pull request. [Guide to Contributing](http://wiki.appcelerator.org/display/guides/How+to+Contribute+Code)
  8. Michael McDonald 2011-12-22

    .
  9. Stephen Tramer 2012-07-26

    Confirmed SDK 2.2.0.014b86f.
  10. Jeff Bonnes 2012-09-26

    Still a problem in SDK 2.1.3RC
  11. Nicolas Gomez 2012-10-05

    I know there may be rights issues, but this bug is VERY bad. Can someone PLEASE provide a fix.
  12. Vitr 2013-04-25

    Any news regarding this bug? I have the same problem in the latest SDK Version (3.1) and it is really annoying :-(
  13. Michael McDonald 2013-06-18

    Seriously? This bug, for which a fix was already given, is still unaddressed after *2 years*??
  14. Olga Romero 2013-06-24

    I reproduced the issue, using: Appcelerator Studio, build: 3.1.1.201306131423 Titanium SDK, build: 3.1.1GA iPhone 5 iOS 7.0 Xcode5 CLI 3.1.1 KitchenSink Version 3.1.1.GA
        var tg = Ti.UI.createTabGroup();
        var fw = null;
        for (var i=0; i<9; i++) {
            var f = function(i) {
                var w = Ti.UI.createWindow({
                    title: 'Tab ' + i,
                    backgroundColor: '#fff'
                });
                var t = Ti.UI.createTab({
                    title: w.title,
                    window: w,
                    icon:'KS_nav_ui.png'
                });
         
                if (i > 0) {
                    var l = Ti.UI.createLabel({
                        text: w.title + ' Label'
                    });
                    w.add(l);
         
                    var btn = Ti.UI.createButton({
                        top: i*40 - 20, height: 35,
                        left: 100, width: 120,
                        title: 'Jump to Tab ' + i
                    });
         
                    btn.addEventListener('click', function(e) {
                        tg.setActiveTab(t);
                    });
         
                    fw.add(btn);
         
                } else {
                    fw = w;
                }
         
                tg.addTab(t);
            }(i);
        }
         
        tg.open();
        
        
  15. Ingo Muschenetz 2013-06-24

    [~kelek] Apologies, but we couldn't use the previously posted solution. I have scheduled this for an upcoming release.
  16. Vishal Duggal 2013-07-22

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/4469
  17. Pragya Rastogi 2013-10-17

    Tested with: OSX: 10.8.5 Xcode:5.0 Appcelerator Studio: 3.2.0.201310152355 SDK:3.2.0.v20131016191202 acs:1.0.7 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processo:1.0.3
  18. Michael McDonald 2014-10-20

    This issue, although fixed last year, appears to be back in Titanium 3.4.0.GA + iOS 8.0.2

JSON Source