#import "ViewController.h"

@implementation ViewController
@synthesize mlabel;

- (void)viewDidLoad
{
	[super viewDidLoad];
	arrayNo = [[NSMutableArray alloc] init];
	[arrayNo addObject:@" Hello "];
	[arrayNo addObject:@" Hai "];
	[arrayNo addObject:@" Picker "];
	[arrayNo addObject:@" Simple "];
	[arrayNo addObject:@" example "];

	[pickerView selectRow:1 inComponent:0 animated:NO];
	mlabel.text= [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]];
}

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

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
	mlabel.text= [arrayNo objectAtIndex:row];
}

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

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
	return [arrayNo objectAtIndex:row];
}

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning
{
	// Releases the view if it doesn't have a superview.
	[super didReceiveMemoryWarning];

	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload
{
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

- (void)dealloc
{
	[super dealloc];
}
@end
 

2 Comments

  1. Kiersten Sendejo June 12, 2011 at 11:21 pm

    Outstanding article, the majority of the data was particularly informative.

     
  2. Pingback: hwo to use PickerView in iPhone (UIPickerView ) « PriyeshSheth (M)+91 909 979 5049

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.