This post deals with using UIPickerView in an application
Lets say the ViewController class in which UIPickerView is to be populated is myViewController
Open myViewController.xib
Drag UIPickerView from Library and add it to the view as shown below
Now come to myViewController.h file
Add the following lines of code highlighted
Now move to myViewController.m
Add the following code
@synthesize picker;
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return 3;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return @"john";
}
The above delegate methods take care of following conditions
In the above code we have assumed that number of components is 1 and there are 3 rows in that component
We want to populate the rows with “john”
Save all this
Now it’s time to make connections, so come again to myViewController.xib
Make connections as shown below
Save and execute and the output is shown below




Pingback: Passing a string from IBAction to a separate View Controller - iPhone Dev SDK Forum
I think you hit a bullsyee there fellas!
Pingback: Time question - iPhone Dev SDK Forum
Grade A stuff. I’m unuesqtoinably in your debt.
Pingback: UILabel background color to be printed in Tableview Cell - iPhone Dev SDK Forum
Son of a gun, this is so hlefpul!
There are no words to desrcbie how bodacious this is.