Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

You must Login before you can answer or comment on any questions.

I get the following error :

Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

when I use navgroups

I basically have multiple windows connected together via nav group using the tutorial below: http://blog.clearlyinnovative.com/post/1624173028/titanium-appcelerator-quickie-navigation-groups

For example to open a new window I use

Ti.App.addEventListener('services', function(event) {
 
 
 
    var cwin = Titanium.UI.currentWindow;
    var swin = Titanium.UI.createWindow();
 
    swin.url = 'service.js';
    swin.zipcode = event.zipcode;
    swin.user_id = event.user_id;
    swin.user_uniqid = event.user_uniqid;
    swin.user_name = event.user_name;
    swin.user_email = event.user_email;
 
    swin.backgroundColor = '#f7f7f7';
 
    swin._parent = cwin;
    swin.navGroup = cwin.navGroup;
    swin.rootWindow = cwin.rootWindow;
    cwin.navGroup.open(swin);
});
and that window where the code above is was opened in a similar way.

So I followed the tutorial above to have multiple windows in a navgroup. Window 1 -> Window 2 -> window 3 -> window 1 -> window 2 etc

I get the error when i try to go back to previous windows

what can I do?

— asked 8 months ago by Weina Scott
2 Comments
  • when a user clicks on a button, the services event listener is executed.

    button1.addEventListener('click', function() {
        Ti.App.fireEvent('services', {
            zipcode : win.zipcode,
            user_id : win.user_id,
            user_uniqid : win.user_uniqid,
            user_name : win.user_name,
            user_email : win.user_email
        });
    });

    — commented 8 months ago by Weina Scott

  • if the button is on the same window (is it?) as the event listener, why not create the window directly inside the the 'onClick' callback?

    — commented 8 months ago by Richard Lustemberg

1 Answer

Accepted Answer

I have not looked at the tutorial code, but at first glance I can see that if you open windows in this way, you end up with trouble. Every window you open sets an Ti.App event listener, which stays in the global scope after you close the window. So , when the event fires, all those event listeners will open a window. You see one window opening , but in fact you are opening a growing amount of windows every time. If you are staggering windows this way, you'll need to use an eventlistener at a different scope (perhaps on the window level). In any case, make sure that you remove the event listener when the window closes. To do that reference the callback with a variable first

function openWindow (event){
 var cwin = Titanium.UI.currentWindow;
    var swin = Titanium.UI.createWindow();
 
    swin.url = 'service.js';
    swin.zipcode = event.zipcode;
    swin.user_id = event.user_id;
    swin.user_uniqid = event.user_uniqid;
    swin.user_name = event.user_name;
    swin.user_email = event.user_email;
 
    swin.backgroundColor = '#f7f7f7';
 
    swin._parent = cwin;
    swin.navGroup = cwin.navGroup;
    swin.rootWindow = cwin.rootWindow;
    cwin.navGroup.open(swin);
}
Ti.App.addEventListener('services',openWindow)
Titanium.UI.currentWindow.addEventListener ('close', function (){
    Ti.App.removeEventListener('services',openWindow)
});

— answered 8 months ago by Richard Lustemberg
answer permalink
4 Comments
  • unfortunately, Titanium.UI.currentWindow.addEventListener ('close', function (){ alert(1); Ti.App.removeEventListener('services',openWindow) }); is never called because the window never closes.... I put an alert(1) in the function, and that is never called.

    — commented 8 months ago by Weina Scott

  • I should have used a reference :

    cwin.addEventListener ('close', function (){
        Ti.App.removeEventListener('services',openWindow)
    });// put this inside the openWindow() callback
    In any case, I've noticed that you are using file url's , and that's not a good practice, although the original Kitchen Sink was written using that approach. As I have never written Titanium code like this, I don't know exactly the scope of the Titanium.UI.currentWindow variable. That reference is only available when using file url's and creating multiple execution contexts. Perhaps you can post more code to see if there's another reason for the window not closing. Anyway, I would not advise to use that approach to learn Titanium.

    — commented 8 months ago by Richard Lustemberg

  • that does not work ... still gives me the same problem. Also, how would you pass in the file name for efficiency?

    — commented 8 months ago by Weina Scott

  • Show 1 more comment

Your Answer

Think you can help? Login to answer this question!