I am trying to make a button for the user where he will be able to choose between 5 different options. I have in mind something like an one line button where one option will be preselected and when the user presses the button the 5 options would be displayed for the user to choose. In the objects library the closest i can find to that is the picker view , but its too big for my screen and it displays all the options , as i only want one to be displayed in the beginning and when the user hits the button all the options so that he can pick a different one if he likes. Is there a button like this on xcode that i am missing or should i customize a picker view or something?
            Asked
            
        
        
            Active
            
        
            Viewed 180 times
        
    1
            
            
        - 
                    Go through http://stackoverflow.com/questions/1047114/how-do-i-use-a-uisegmentedcontrol-to-switch-views – san Jun 19 '12 at 10:08
- 
                    Spend some time familiarizing yourself with the objects available from Interface Building. The UISegmentedControl (shown below) sounds like exactly what you need. – LJ Wilson Jun 19 '12 at 10:09
2 Answers
2
            
            
        How about a UISegmentedControl with 5 buttons?

phix mentioned the UITextField/UIPicker Combo like this

 
    
    
        Damo
        
- 12,840
- 3
- 51
- 62
- 
                    I thought of that too BUT my options are cities and not numbers...So they cant fit in the screen like this. – donparalias Jun 19 '12 at 10:18
2
            One option would be a segmented control, but that gets too large when you have many options.
I'd recommend to use a customized UITextfield with a UIPickerView as inputView. So the user can only select the text from the picker, not through the keyboard.
It's also possible to do that with a UIButton, that would require to subclass UIButton.
Here is a tutorial on how to achieve this: http://nomtek.com/tips-for-developers/working-with-pickers/
 
    
    
        Felix
        
- 35,354
- 13
- 96
- 143
- 
                    +1 because I'm guilty of updating my answer with an example of your answer :-/ – Damo Jun 19 '12 at 10:21
- 
                    
