Tutorial details

UIPicker | App Code for Sale | Preview

UIPicker | iOS Tutorial

How to use UIPIckers in your apps

Overview PAGE TOP

Reference: http://www.geekylemon.com/xcode-uipicker

In this tutorial i will be showing you how to use UIPIckers in your apps


  • 1 UIPicker
  • 1 Label

This feature is handy for letting users select a vast amount of info to display in your app

ViewController.h PAGE TOP

@interface ViewController : UIViewController {
IBOutlet UILabel *label;
IBOutlet UIPickerView *Picker;
NSArray *PickerData;

@property (retain, nonatomic) IBOutlet UIPickerView *Picker;
@property (retain, nonatomic) NSArray *PickerData;

ViewController.m PAGE TOP

@implementation ViewController
@synthesize Picker,PickerData;

- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSArray *array = [[NSArray alloc] initWithObjects:@"One",@"Two",@"Three",@"Four", nil];
self.PickerData = array;

- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.

-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return [PickerData count];

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [self.PickerData objectAtIndex:row];

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
int select = row;
if (select == 0) {
label.text = @"One Is Selected";
} else
if (select == 1) {
label.text = @"Two Is Selected";
} else
if (select == 2) {
label.text = @"Three Is Selected";
} else
if (select == 3) {
label.text = @"Four Is Selected";

Reference PAGE TOP


0 Comments Leave a comment

Please login in order to leave a comment.

Newest first

to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.