restoring state to a navigation controller with table views

Discussion in 'iOS Programming' started by North Bronson, Aug 8, 2009.

  1. North Bronson macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #1
    Here's something I've been wondering for a while:

    Take a look at one of Apple's apps (like Mail) that restores state across a Navigation Controller. If you start your app on a leaf controller and you pop back to a table view, the "selected" table cell de-selects, as if it was selected to push you to the leaf in the first place.

    I can't figure out the best way to do this. Right now, I have a working app that saves state.

    I thought about, while restoring the state, actually calling the appropriate tableView:didSelectRowAtIndexPath: method, but this would then load the appropriate table view, which seems like a waste if I'm just skipping over that view in the first place. This is why my current code to restore does a programmatic push without touching the table view. This doesn't give me the highlighted cell when I pop back, though.

    Any ideas?
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Code:
    selectRowAtIndexPath:animated:scrollPosition: 
    would seem to be what you're looking for.
     
  3. North Bronson thread starter macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #3
    I thought about this, but then I'm back at my original problem.

    If my hierarchy has three levels with a leaf controller at the end, restoring to the leaf controller pushes through two table view controllers. Using the selectRowAtIndexPath:animated:scrollPosition: method would load two separate table views "on the way", but the programatic push I'm using now bypasses loading the table views.

    I guess I could try something in the viewWillAppear:animated: for each table view controller that would check to see if the table view should "de-select" a cell. There might be a cleaner way, though
     
  4. rick.andrews macrumors newbie

    Joined:
    Feb 24, 2008
    #4
    See Apple sample code DrillDownSave

    This is a little late, but if you're still looking: search the ADC iPhone Reference Library for "DrillDownSave" -- it sounds exactly what you were looking for.
     

Share This Page