Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

NavigationGroup - Custom back button persists after close.

The below code creates a NavigationGroup with the first window containing a custom 'back' button to close itself and another button to open a second window. The second window has a custom 'back' button to close itself.

The custom 'back' buttons don't work in 1.3. I applied this patch to get them to work:
925-cant-close-window-in-nav-group

The issue

1 Click on the 'back' button in the second window.

2 The second window closes.

3 The first window is shown.

4 The second window's 'back' button shows on the first window.


In step 4 I would expect the first window's back button to show on the first window.

If I remove the first window's 'back' button and run through steps 1 through 3, when the first window is shown it has no 'back' button as expected.

I also tried setting the left nav buttons in an 'open' listener for each window but this didn't help either.

Bug, no?

  // window 1 setup
  var win1 = Titanium.UI.createWindow({
      backgroundColor:"red",
      title:"Window 1"
  });

  var openWin2Button = Titanium.UI.createButton({
    title: 'open win 2',
    height:40,
    width:200
  });

  openWin2Button.addEventListener( 'click', function() {
    nav.open(win2);
  });

  win1.add(openWin2Button);

  var closeWin1Button = Titanium.UI.createButton({
    title: 'Close me'
  });
  closeWin1Button.addEventListener( 'click', function() {
    nav.close(win1);
  })
  win1.setLeftNavButton(closeWin1Button);


  // window 2 setup
  var win2 = Titanium.UI.createWindow({
    backgroundColor: "#0f0",
    title: "Window 2"
  });

  var closeWin2Bbutton = Titanium.UI.createButton({
    title: 'close win2'
  });

  closeWin2Bbutton.addEventListener( 'click', function() {
    nav.close(win2);
  });

  win2.setLeftNavButton(closeWin2Bbutton);


  // nav group setup
  var nav = Titanium.UI.iPhone.createNavigationGroup({
     window : win1
  });

  var win = Titanium.UI.createWindow();
  win.add(nav);
  win.open();
— asked June 2nd 2010 by Donnie Tognazzini
  • back
  • button
  • close
  • navigationgroup
  • window
0 Comments

4 Answers

  • Anybody? I'm pretty sure this is a bug, but I don't see it on lighthouse.

    — answered June 3rd 2010 by Donnie Tognazzini
    permalink
    0 Comments
  • bump. I've got the same issue here

    — answered September 30th 2010 by Nate Rambarran
    permalink
    0 Comments
  • I am having exactly the same issue, any news on this?

    — answered November 20th 2010 by Antonio Silveira
    permalink
    0 Comments
  • My guess, based on the way the NavigationController works in the iPhone SDK, is the back buttons are persisting because the navigation controller hasn't changed.

    you are just pushing view controllers on to a stack that is managed by the navigationGroup. Placing buttons in the NavigationBar and the Navigation Bar is owned by the NavigationGroup so they are not going to go away unless you remove the buttons yourself.

    — answered November 20th 2010 by Aaron Saunders
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.