views:

124

answers:

2

Hi,

I'm developing my first iPhone app and want to allow the user to select the scope of their search in a more complex way than the 'scope buttons' permit.

The app is related to wines and I want to the user to be able to select the 'color' (Red, White, Blush, etc.) first, and then select the type/varietal within that category. Right now, I'm using the UISearchBar's scope buttons for the colors and tapping the button opens a view with the selection of colors. This is okay except that once the 'Red' button has been selected, I can't select it a second time to change my choice of type (e.g., change from 'Merlot' to 'Syrrah', etc.) If there's a better way to do this, I'm willing to scrap my method and start from scratch.

Thanks!

+1  A: 

Why can't you click it a second time?

It would just use the standard scope bar with one button per choice (color, type. etc.). When a button is clicked, pop up UIPickerView with the possible values. When a value is chosen, display it in the button.

If there are just two choices, you could also present one UIPickerView with two segments.

Rengers
It would be great if I _could_ click it a second time but it doesn't fire an event -- that I know of. Is there something besides the "shouldReloadTableForSearchScope" delegate method available to know when the scope buttons have been clicked? BTW: I am using a UIPickerView to choose the types once the color has been chosen.
Mark Pemburn
A: 

Sometimes it takes asking the question for the answer to come to you on its own. I put the following line in the "viewDidDisappear" delegate method:

[self.searchDisplayController.searchBar setSelectedScopeButtonIndex: -1];

What this does is to set the currently active scope button to 'nothing' so that when you return to the original view, none of the scope buttons are selected. Thus, you can select any of them, including the one you selected the last time. This is exactly what I wanted to do.

I don't know if this is a 'best practice' but it'll serve.

Mark Pemburn
Ok, good to hear that it's been solved! Perhaps not the best practice to use a scope bar like this indeed. I hope Apple approves this UI design.
Rengers
Still a lot to learn, to be sure. Even though this works, I'm going to abandon it in favor of a table to select what had been 'scope' items. Don't want Papa Apple to frown on my brainchild!
Mark Pemburn