On Tue, 2 Nov 2010 12:15:09 -0400, Phillip Mills <phillip.mil...@acm.org> said:
>I have an application with a split view, master/detail design.  The 'master' 
>items are dynamically created and vary in number.  When I start the 
>application, I load these for use by the table view's data source during the 
>root view controller's viewDidLoad and everything works quite well.  Except....
>
>I'd like the application to automatically select the item that was selected 
>when it was last exited.  I can't do this in viewDidLoad because the table 
>hasn't been populated yet.  There also seems to be no delegate method for 
>dealing with the end of a set of cell requests.  Currently, my best idea is to 
>subclass UITableView, override layoutSubviews so that I know when 'super' has 
>finished, and (if it's the first time through) append selection logic.  This 
>strikes me as a clumsy was of doing something that probably should be simple.
>
>Suggestions for a cleaner approach would be appreciated.

Maybe I'm missing something, but when you say reloadData, the *next* line is 
not executed until the data have been reloaded. So now you can select the 
previously selected item. The TidBITS News app does this, for example, and it's 
as simple as that: after I reload the data, I look to see whether there was a 
selection index saved off in the user defaults, and if there was, I select it. 
Of course I also remove that info from the user defaults so this won't happen 
again later as the app continues to run and the data gets reloaded again. t.

--
matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to