PDA

View Full Version : Segmented Control Reset




mcnuggets
Jan 2, 2009, 11:43 PM
I have an app similar to the SQLiteBook example from Apple and I put a segmented controller with 3 values (ex: low, med, high). When I add an entry, the segmented controller is set to the value of low when the view is loaded. Lets say, I change the value to Med and save it. When I try to add another entry... the segmented controller is set to the last value... in this case... Med. My question is... how do I reset the segmented controller to Low everytime I add a new value? I've checked Apple's docs and can't find the answer.



dejo
Jan 3, 2009, 12:20 AM
When you add the new value, just do a:
segmentedControl.selectedSegmentIndex = 0;

mcnuggets
Jan 3, 2009, 06:07 PM
When you add the new value, just do a:
segmentedControl.selectedSegmentIndex = 0;

Thanks I'm trying that but it still wont work. Maybe I'm adding it to the wrong section.

So basically here's the problem:
1) Launch the application
2) Click Add
3) Choose Status "Medium"
4) Click back to Todo Items.
5) Click Add
6) Now you notice that the Segment control is saved on "Medium". I want it to change to "Low" everytime this view gets called upon.

Here's the location of the zip file example that I'm playing with:
http://icodeblog.com/wp-content/uploads/2008/09/todo-part-4.zip

Please assist if you can... because I'm so frustrated right now. :(

dejo
Jan 3, 2009, 10:41 PM
Try adding the following line to the end of addTodo: in RootViewController.m:
self.todoView.todoPriority.selectedSegmentIndex = 0;