UIPicker as Subview - iphone

I'm trying to add a UIPicker as a subview, but can't quite figure it out. I've added a second UIView control with a UIPickerview to my nib (NewWorkoutViewController.xib). My code is as follows:
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView
{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component
{
return [list count];
}
-(NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [list objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSLog(#"Selected item: %# index of selected item: %i", [list objectAtIndex:row], row);
}
-(void)viewDidLoad
{
[super viewDidLoad];
counterInt = 0;
list = [[NSMutableArray alloc] init];
[list addObject:#"red"];
[list addObject:#"blue"];
[list addObject:#"yellow"];
[list addObject:#"pink"];
}
-(IBAction)routePicker
{
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 480, 320, 216)];
UIPickerView *thePickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,0,320,216)];
[myView addSubview:thePickerView];
[self.view.superview addSubview:myView];
}
My subview is not popping up as expected.

It is not clear why do you add the picker in code if you've already added it in IB... Regarding the code you posted, try to add picker to controller's view, not to the superview (and do not forget to set its delegate):
-(IBAction)routePicker
{
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 480, 320, 216)];
UIPickerView *thePickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,0,320,216)];
thePickerView.delegate = self;
[myView addSubview:thePickerView];
[self.view addSubview:myView];
}
Edit: You initialize you myView instance with a frame that is likely to be outside of the visible area (frame's origin y coordinate is 480), try to set it to 0:
// Bad
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 480, 320, 216)];
// Good?
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)];

Check out this example from Apple
Date Cell Picker

Related

Invalid context error on iOS 7 when adding a UIPickerView inside a UIActionSheet?

I have an UIPickerView inside an UIActionSheet and have done that in a way suggested by many others here at SO:
Add UIPickerView & a Button in Action sheet - How?
how to add UIPickerView in UIActionSheet
The solutions have worked fine until now when testing my app on iOS 7. It still works but I got a lot of "invalid context 0x0" warnings during runtime in Xcode.
The errors are coming with a nice message too:
CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Could it be that Apple finally want to stop this kind of solution or is it something we can work around or fix?
A workaround for this 'invalid context 0x0' warning is to init the UIActionSheet with a non nil title (non-nil buttons also resolve the error but result in visual artefacts).
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#""
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
You will then need to adjust the actionsheet's frame for it to position properly in both iOS7 and previous versions (make sure to do this after the showInView method).
CGRect newFrame = actionSheet.frame;
newFrame = self.view.bounds.size.height - myCustomPicker.frame.size.height;
newFrame = myCustomPicker.frame.size.height;
actionSheet.frame = newFrame;
As the comments above point out, the UIActionSheet is not designed to be subclassed or take other views.
More info here at Apple:
https://developer.apple.com/library/ios/documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006801-CH3-DontLinkElementID_2
One approach is to look closer at the DateCell sample code and change that to use an UIPickerView instead:
https://developer.apple.com/library/ios/samplecode/DateCell/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008866-Intro-DontLinkElementID_2
-(void)viewDidLoad
{
[super viewDidLoad];
// Make Your own Action sheet
myCustomeActionSheet=[[UIView alloc] initWithFrame:CGRectMake(0,self.view.frame.size.height+1,self.view.frame.size.width,215)];
myCustomeActionSheet.backgroundColor=[UIColor whiteColor];
[self.view addSubview:myCustomeActionSheet];
}
// Use this code To Open Date Picker Or UiPicker View
-(void)OpenActionSheet:(Boolean)isDatePickere
{
SelectedString=Nil;
if (datepickerView) {
[datepickerView removeFromSuperview];
datepickerView=Nil;
}
if (picker) {
[picker removeFromSuperview];
picker=Nil;
}
if (isDatePickere)
{
// Add the Datepicker
datepickerView= [[UIDatePicker alloc] init];
datepickerView.datePickerMode = UIDatePickerModeDateAndTime;
datepickerView.minimumDate=[NSDate date];
[myCustomeActionSheet addSubview:datepickerView];
}
else
{
// Add Picker View
picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,40, 320, 216)];
picker.showsSelectionIndicator=YES;
picker.dataSource = self;
picker.delegate = self;
[myCustomeActionSheet addSubview:picker];
}
UIToolbar *tools=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 0,320,40)];
tools.barStyle=UIBarStyleBlackOpaque;
[myCustomeActionSheet addSubview:tools];
UIBarButtonItem *doneButton=[[UIBarButtonItem alloc]initWithTitle:#"Done" style:UIBarButtonItemStyleBordered target:self action:#selector(btnActinDoneClicked)];
doneButton.imageInsets=UIEdgeInsetsMake(200, 6, 50, 25);
UIBarButtonItem *CancelButton=[[UIBarButtonItem alloc]initWithTitle:#"Cancel" style:UIBarButtonItemStyleBordered target:self action:#selector(btnActinCancelClicked)];
UIBarButtonItem *flexSpace= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
NSArray *array = [[NSArray alloc]initWithObjects:CancelButton,flexSpace,flexSpace,doneButton,nil];
[tools setItems:array];
//picker title
UILabel *lblPickerTitle=[[UILabel alloc]initWithFrame:CGRectMake(60,8, 200, 25)];
lblPickerTitle.text=#"Select";
lblPickerTitle.backgroundColor=[UIColor clearColor];
lblPickerTitle.textColor=[UIColor whiteColor];
lblPickerTitle.textAlignment=NSTextAlignmentCenter;
lblPickerTitle.font=[UIFont boldSystemFontOfSize:15];
[tools addSubview:lblPickerTitle];
[UIView animateWithDuration:0.5 animations:^{
myCustomeActionSheet.frame=CGRectMake(0,self.view.frame.size.height-myCustomeActionSheet.frame.size.height,myCustomeActionSheet.frame.size.width,myCustomeActionSheet.frame.size.height);
} completion:^(BOOL finished)
{
}];
}
pragma -mark Bar Button Action
-(void)btnActinDoneClicked
{
if (SelectedString==Nil)
{
SelectedString=[pickerArrayList objectAtIndex:0];
}
if (datepickerView)
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSLocale *posix = [[NSLocale alloc] initWithLocaleIdentifier:#"en_US_POSIX"];
[dateFormatter setLocale:posix];
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
[dateFormatter setDateFormat:#"DD/MM/yy hh:mm a"];
[selectedButton setTitle:[dateFormatter stringFromDate:datepickerView.date] forState:UIControlStateNormal];
}
else
[selectedButton setTitle:SelectedString forState:UIControlStateNormal];
[self performSelector:#selector(btnActinCancelClicked) withObject:nil afterDelay:0.10];
}
-(void)btnActinCancelClicked
{
[UIView animateWithDuration:0.5 animations:^{
viewActiobSheetView.frame=CGRectMake(0,self.view.frame.size.height+1,self.view.frame.size.width,viewActiobSheetView.frame.size.height);
}
completion:^(BOOL finished)
{
[datepickerView removeFromSuperview];
[picker removeFromSuperview];
datepickerView=Nil;
picker=Nil;
}];
}
pragma -mark PickerView Delegate
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent: (NSInteger)component reusingView:(UIView *)view
{
UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
label.text=[pickerArrayList objectAtIndex:row];
label.textAlignment=NSTextAlignmentCenter;
label.textColor=[UIColor blackColor];
return label;
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [pickerArrayList count];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
SelectedString=[pickerArrayList objectAtIndex:row];
}

when picker view selected keyboard still visible

i have a text field and picker view.when i select the text field picker view is appearing and if i select row in picker still my textfield is editable. i want to set textfield only in drop down list.and one more problem my key board is visible when i select the textfield
- (void)textFieldDidBeginEditing:(UITextField *)textField {
[txtstate resignFirstResponder];//this is to hide key board
txtstate.inputView=pickerView;
ViewForValuePicker = [[UIView alloc]initWithFrame:CGRectMake(43,337, 212, 160)];
UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(43, 0, 212, 30)];
toolBar.barStyle = UIBarStyleBlackOpaque;
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(doneBtnPressToGetValue)];
[toolBar setItems:[NSArray arrayWithObject:btn]];
[ViewForValuePicker addSubview:toolBar];
pickerView = [[UIPickerView alloc]init] ;
pickerView.frame=CGRectMake(43, 30, 212, 140);
pickerView.delegate = self;
pickerView.dataSource= self;
pickerView.showsSelectionIndicator = YES;
[ViewForValuePicker addSubview:pickerView];
errstate.hidden=YES;
[testScroll addSubview:ViewForValuePicker];
[pickerView setHidden:NO];
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel *retval = (id)view;
if (!retval) {
retval= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f,
[pickerView rowSizeForComponent:component].width,
[pickerView rowSizeForComponent:component].height)] ;
}
retval.text = [[arr objectAtIndex:row]objectForKey:#"Code"];
retval.font = [UIFont fontWithName:#"Helvetica-Bold" size:12];
return retval;
}
- (void)doneBtnPressToGetValue{
[pickerView resignFirstResponder];
[pickerView removeFromSuperview];
txtcity.text=nil;
autocompleteTableView.hidden=YES;
[ ViewForValuePicker removeFromSuperview];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
txtLId.text=[[arr objectAtIndex:row] valueForKey:#"LId"];
txtstate.text= [[arr objectAtIndex:row] valueForKey:#"Code"];
//txtstate.userInteractionEnabled=NO;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [arr count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
return [[arr objectAtIndex:row] valueForKey:#"Code"];
}
Hello try and update following code with your code or check full code at http://pastie.org/6569798 :-
First define
UIActionSheet *actionSheet;
in header file(.h).
- (void)createActionSheet {
if (actionSheet == nil)
{
actionSheet = [[UIActionSheet alloc] initWithTitle:#"Select" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerToolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
[flexSpace release];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(doneBtnPressToGetValue)];
[barItems addObject:doneBtn];
[doneBtn release];
[pickerToolbar setItems:barItems animated:YES];
[barItems release];
[actionSheet addSubview:pickerToolbar];
[pickerToolbar release];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0,0,320, 464)];
}
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if(textField==txtstate)
{
pickerView = [[UIPickerView alloc]init] ;
pickerView.frame=CGRectMake(0, 44, 320, 420);
pickerView.delegate = self;
pickerView.dataSource= self;
pickerView.showsSelectionIndicator = YES;
[pickerView setHidden:NO];
[self createActionSheet];
[actionSheet addSubview:pickerView];
[textField resignFirstResponder];
}
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *retval = (id)view;
if (!retval) {
retval= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f,
[pickerView rowSizeForComponent:component].width,
[pickerView rowSizeForComponent:component].height)] ;
}
retval.text = [arr objectAtIndex:row];
retval.font = [UIFont fontWithName:#"Helvetica-Bold" size:12];
return retval;
}
- (void)doneBtnPressToGetValue
{
[txtstate resignFirstResponder];
[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
[actionSheet release];
actionSheet = nil;
}
Assign your textfield.inputview in viewDidLoad itself with pickerView.
In textFieldDidBeginEditing - no more code required.
Also use your UIPickerViewDelegate methods as it is.
If you want to have just the pickerview show up when you select the text field, take all of the code you have right now in textFieldDidBeginEditing and move it into viewDidLoad. If you initialize txtstate.inputView=pickerView; before hand it will replace the keyboard as the main input.

uipicker view implementation on action sheet

I have implemented the UIPicker view concept on action sheet, it is working properly but one thing it is not displaying properly that is row index. There is no highlighted row in the picker view.
I have uploaded the image. Please give me the solution for it.
Following is the code which I am using:
-(IBAction)clickformedtype:(id)sender
{
UIActionSheet *asheet = [[UIActionSheet alloc] initWithTitle:#"Select medication type" delegate:self
cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"Select", nil];
[asheet showInView:[self.view superview]]; //note: in most cases this would be just self.view, but because I was doing this in a tabBar Application, I use the superview.
[asheet setFrame:CGRectMake(0, 117, 320, 383)];
[asheet release];
}
-(void)willPresentActionSheet:(UIActionSheet *)actionSheet {
medicationtypepicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, 320, 216)];
medicationtypepicker.delegate = self;
medicinetypearray = [[NSMutableArray alloc]initWithObjects:#"ml",#"capsules",#"eyedrops", nil];
//medicationtypepicker = [[NSMutableArray alloc]initWithObjects:#"ml",#"capsules",#"eyedrops", nil];
//medicationtypepicker.datePickerMode = ui;
//Configure picker...
// [medicationtypepicker setMinuteInterval:1];
[medicationtypepicker setTag: kDatePickerTag];
//Add picker to action sheet
[actionSheet addSubview:medicationtypepicker];
// [medicationtypepicker release];
//Gets an array af all of the subviews of our actionSheet
NSArray *subviews = [actionSheet subviews];
[[subviews objectAtIndex:SelectButtonIndex] setFrame:CGRectMake(20, 266, 280, 46)];
[[subviews objectAtIndex:CancelButtonIndex] setFrame:CGRectMake(20, 317, 280, 46)];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
UIPickerView
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [medicinetypearray count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
return [medicinetypearray objectAtIndex:row];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
medicinetype.text=[medicinetypearray objectAtIndex:row];
//medicationtypepicker.hidden = YES;
}
Thanks in advance.
UIPickerView has a property called "showsSelectionIndicator" - set this to YES also set autoresizingMask to UIViewAutoresizingFlexibleWidth as follows...
mTimePicker.showsSelectionIndicator = YES;
mTimePicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
Try to set property showsSelectionIndicator to YES:
medicationtypepicker.showsSelectionIndicator = YES;

how to add uipickerview as as subview to mainview in iphone?

I have one application in which when user clicks a button i want to open uipickerview as as subview to main view and after user selects an item it should be removed from main view.(drop down kind of functionality).For that i have written code as below:
-(void)showPrefPicker:(id)sender
{
UIView *subView=[[UIView alloc] init];
subView.frame=CGRectMake(180, 120, 150, 150);
pickerView = [[UIPickerView alloc] init];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
pickerView.frame=CGRectMake(190, 130, 100, 100);
subView.backgroundColor=[UIColor blackColor];
[subView addSubview:pickerView];
[self.view addSubview:subView];
[pickerView release];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
return 1;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSLog(#"selected object is %#",[arraypref objectAtIndex:row]);
//[pickerView ]
//mlabel.text= [arrayNo objectAtIndex:row];
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [arraypref count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
return [arraypref objectAtIndex:row];
}
but is only showing subview in the main view not the pickerview.how can i do that any tutorial or source code for that?
Better you use
to hide
pickerview.hidden=YES;
to show
pickerview.hidden=NO;
Try changing the frame of the pickerView as
pickerView.frame = CGRectMake(10,10,100,100);
in your code subView.frame=CGRectMake(180, 120, 150, 150);
and pickerView.frame=CGRectMake(190, 130, 100, 100);
picker view is a subview of your 'subView'
here pickerview's frame starts out of bounds of subview ie origin x is 190. but the width of the subview is only 150.
so the correct code is
pickerView.frame=CGRectMake(0, 0, 100, 100);
since pickerview is a subview of a custom view. it should be in the frame of its parent view.

Edit 2 uitextfield by turn with a select in uipickerview

I have 2 instances of UITextField and 1 instance of UIPickerView. UIPickerView is able to update data into
UITextField in didSelectRow:(NSInteger)row inComponent:(NSInteger)component. But how do I update 2 UITextField from UIPickerView when the user touch the UITextView?
Thanks. :)
you will need to make the UIPickerView the inputView of the textfields, i have made an example.
.h file:
#interface aViewController : UIViewController <UIPickerViewDelegate,UIPickerViewDataSource> {
UITextField * textField0;
UITextField * textField1;
UIPickerView * pickerView;
UIToolbar * toolBar;
NSArray * items0;
NSArray * items1;
}
-(void)cancel;
-(void)close;
#end
.m need something like the following:
- (void)viewDidLoad
{
[super viewDidLoad];
textField0 = [[UITextField alloc] initWithFrame:CGRectMake(10.f, 20.0f, 100.f, 30.f)];
textField1 = [[UITextField alloc] initWithFrame:CGRectMake(130.f, 20.0f, 100.f, 30.f)];
textField0.backgroundColor = [UIColor grayColor];
textField1.backgroundColor = [UIColor grayColor];
pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320.f, 200.f)];
// Do any additional setup after loading the view from its nib.
[self.view addSubview:textField0];
[self.view addSubview:textField1];
toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320.f, 44.f)];
UIBarButtonItem * cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:#selector(cancel)];
UIBarButtonItem * doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(close)];
toolBar.items = [NSArray arrayWithObjects:doneButton,cancelButton, nil];
items0 = [[NSArray alloc] initWithObjects:#"dogs",#"cats",#"llamas",#"emus", nil];
items1 = [[NSArray alloc] initWithObjects:#"bone",#"catnip",#"hay", nil];
[doneButton release];
[cancelButton release];
pickerView.showsSelectionIndicator = YES;
pickerView.delegate = self;
pickerView.dataSource = self;
textField1.inputView = pickerView;
textField0.inputView = pickerView;
textField1.inputAccessoryView = toolBar;
textField0.inputAccessoryView = toolBar;
}
#pragma mark - actions
-(void)cancel
{
//reset the values to the original values on cancel...
//do that here.
[textField0 resignFirstResponder];
[textField1 resignFirstResponder];
}
-(void)close
{
textField0.text = [items0 objectAtIndex:[pickerView selectedRowInComponent:0]] ;
textField1.text = [items1 objectAtIndex:[pickerView selectedRowInComponent:1]] ;
[textField0 resignFirstResponder];
[textField1 resignFirstResponder];
}
#pragma mark - pickerview handling
-(float)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{
return 130.f;
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (component==0) {
return [items0 objectAtIndex:row];
}
return [items1 objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (component==0) {
textField0.text = [items0 objectAtIndex:row];
return;
}
textField1.text = [items1 objectAtIndex:row];
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (component ==0) {
return [items0 count];
}
return [items1 count];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 2;
}
I haven't included any clean-up code.