UIActionSheet conditions help

Discussion in 'iOS Programming' started by uaecasher, Feb 8, 2011.

  1. uaecasher macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #1
    Hello,

    I'm using a UIActionSheet to let users to choose either a camera or photo library, how ever if a user has an iPod he shouldn't be presented with camera option, so i want to know how to do a conditional inside an action sheet, thank you.

    here is my code:

    Code:
    
    -(IBAction)selector {
        
        UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                      initWithTitle:@"Choose Source Type?"
                                      delegate:self
                                      cancelButtonTitle:nil
                                      destructiveButtonTitle:nil
                                      otherButtonTitles:@"Select From Library", @"Capture From Camera", nil];
        [actionSheet showInView:self.view];
        [actionSheet release];
        
    }
    
    
    

    Code:
    
       if ( (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]))
    		
    	{	
            
         
    	}	
    	
    
    
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    This phrase doesn't make much sense: "conditional inside an action sheet". You put the code that will display the action sheet inside the condition. Note it's the code, not the sheet that goes inside the conditional.
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    Something to consider: if the app is running on a device with no camera, your action sheet will have only one choice ("Select From Library"). In that case, it doesn't make sense, to me at least, to present the user with one choice and then make them pick it; instead, just take the user to that single option right away.
     
  4. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #4
    i never thought of that, thanks for the idea :D
     

Share This Page