UIPickerView Cell Selected?

Discussion in 'iOS Development' started by Nickll9009, Dec 13, 2008.

  1. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    This is what I have for code for the cells in my UIPickerView

    Code:
    - (UIPickerTableCell*) pickerView:(UIPickerView*)picker tableCellForRow:(int)row inColumn:(int)col
    {
         UIPickerTableCell *cell = [[UIPickerTableCell alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 32.0f)];
    
         switch (row)
         {
             case 0:
    		[ cell setTitle: @"Unlock Slider" ];
    	  break;
    
    	  case 1:
    		[ cell setTitle: @"Power Down Slider" ];
    	  break;
    	
    	  case 2:
    		[ cell setTitle: @"Answer Slider" ];
    	  break;
    		
    	  case 3:
    		[ cell setTitle: @"Dismiss Button" ];
    	  break;
    
    	  case 4:
        		[ cell setTitle: @"Music Button" ];
    	  break;
    
    	  case 5:
    		[ cell setTitle: @"Sync In Progress" ];
    	  break;
    
    	  case 6:
    		[ cell setTitle: @"Incorrect Password" ];
    	  break;
    
    	  
         }
    
         return cell;
    }
    How do I set actions if case1,2,3,4,5,6 are selected?
  2. super fly

    super fly New Member

    Joined:
    Jul 28, 2008
    Messages:
    93
    Likes Received:
    0
    Device:
    iPod touch
    I dont know obj c, but try
    if case = 1 {
    //code to do here
    }
  3. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    I need to do this from a UIPushButton.
  4. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    if case = 1 and pushButton1 = selected {
    //code to do here
    }

    Clearly not the right code, but try putting an "and" or "&&" in there? I'm just guessing.
    Maybe? I don't know any of this code stuff, this is just some language we use at school.
  5. veeloc

    veeloc New Member

    Joined:
    Sep 6, 2008
    Messages:
    815
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    I'm totally not gonna be helpful but don't you need to put a:
    Code:
    {
    		if(button == 1)
    	{
    	
    		YOUR CODE HERE
    
    	}
  6. crizh4x

    crizh4x Active Member

    Joined:
    Sep 19, 2007
    Messages:
    4,474
    Likes Received:
    17
    Device:
    2G iPod touch
    Just use IB to create an event... it would be super easy.

    too bad I can't give you an example since it's in IB.
  7. godogshomie

    godogshomie New Member

    Joined:
    Nov 19, 2007
    Messages:
    558
    Likes Received:
    3
    here you go nickll9009

    Code:
    - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
    {
    switch (row){
    case 0:
    //do action 1
    break;
    case 1:
    //action 2
    break;
    case 2:
    //action 3
    break;
    case 3:
    //action 4
    break;
    case 4:
    //action 5
    break;
    case 5:
    //action 6
    break;
    case 6:
    //action 7
    break;
    }
    }
    

Share This Page