views:

32

answers:

2

Hi,

I would like to use an ActionSheet for sorting options in an app containing many table views with navigation controllers. My problem is that I cant seem to keep the last selected index on the sheet after poping back one level or quitting the app. The index value defaults back to 0 and I just cant seem to change its initial value. Its possibly something trivial but would really appreciate some help with it. Thanks.

A: 

Read some tutorials or books on persistent storage. Core Data or SQLite are available for database needs, or you could store simple values in the NSUserDefaults. That should be enough to get you on your way.

Jasarien
The SQLite database is already made and the sorting works fine,it just resets the buttonindex after quitting and thats what I'd like to solve somehow.
Ernő Simonyi
A: 

Do you mean that you want the UIActionSheet on subsequent appearances to reflect the current setting?

If so, it may not be the correct UI metaphor to use, since it's just a series of buttons, and there is nothing to distinguish one button from another other than which one cancels an operation or is destructive, and neither of those seem to fit the "sort order" setting you want to keep track of.

What about trying a simple UITableView with a UITableViewCell that has an accessoryType of UITableViewCellAccessoryCheckmark? Like in Figure 1-3 here.

jbm
Yes,that is what I'd like to do. The sorting works fine with multiple select sql calls and I was hoping i could somehow keep the last pressed buttonindex but no luck yet. Could you tell what you meant with the accessoryType, I'm not sure how it could help with sorting,but im still a newbie in this so I really might miss something here :).
Ernő Simonyi
I was suggesting that a UIActionSheet may not be the correct UI element to use for what you described, and suggested an alternate that might be better, a UITableView. Check out the Figure I referenced.
jbm
Oh,that's a good idea.So then a modal tableview that on cell touch sorts the main tableview, sounds good.Thanks again.
Ernő Simonyi
You're welcome, and it's good form on StackOverflow to either vote a useful answer "up" or check it off as an "accepted answer." Just saying, since you're new here, no offense taken if you don't :-)
jbm