2. Profile
Ankit Desai
Ph.D. Scholar, IET, Ahmedabad University
Education: M. Tech. CE, B.E. I. T.
Experience: 7.5 Years (Academic and Research)
Research Interest: IoT, Big Data Analytics,
Machine Learning, Data Mining.
3. UIPickerView Control
Drag a UIPickerView on xib
Add delegates after class-name
<UIPickerViewDataSource,UIPickerViewDelegate>
Declare two NSArray in .h file
NSArray *arrItems;
NSArray *arrLocation;
4. Initialize arrays in .m files
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
arrItems=[[NSArray
alloc]initWithObjects:@"iphone",@"android",@"java",@"testing", nil];
arrLocation=[[NSArray
alloc]initWithObjects:@"ahmedabad",@"baroda",@"surat", nil];
}
5. Add delegates methods 1 & 2
// returns the number of 'columns' to display.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{ return 2; }
// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
if (component==0) {
return [arrItems count];
}
else {
return [arrLocation count];
}
}