Segmented Control Reset

Discussion in 'iOS Programming' started by mcnuggets, Jan 2, 2009.

  1. macrumors newbie

    Joined:
    Jan 2, 2009
    #1
    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.
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    When you add the new value, just do a:
    Code:
    segmentedControl.selectedSegmentIndex = 0;
     
  3. thread starter macrumors newbie

    Joined:
    Jan 2, 2009
    #3
    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. :(
     
  4. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Try adding the following line to the end of addTodo: in RootViewController.m:
    Code:
    self.todoView.todoPriority.selectedSegmentIndex = 0; 
    
     

Share This Page