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?
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) });
Your Answer
Think you can help? Login to answer this question!