I'm trying to implement a UIPickerView in a FlipsideViewController, which is just a settings tab.
Here's the relevant code in the .h file:
#class FlipsideViewController;
#protocol FlipsideViewControllerDelegate<UIPickerViewDataSource, UIPickerViewDelegate>
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller;
#end
#property (strong, nonatomic) IBOutlet UIPickerView *Categories;
#property (strong, nonatomic) NSArray *categoriesData;
#property (strong, nonatomic) NSMutableArray* dataArray;
- (int)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
- (NSInteger)Categories:(UIPickerView *)Categories numberOfRowsInComponent:(NSInteger)component;
- (NSString*)Categories:(UIPickerView *)Categories titleForRow:(NSInteger)row forComponent:(NSInteger)component;
Here's the relevant code in the .m file:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_Categories = [[UIPickerView alloc] initWithFrame:CGRectMake((pickerWidth*4/3)/2-pickerWidth/2, 50.0f, pickerWidth, 200.0f)];
_Categories.showsSelectionIndicator = true;
[_Categories selectRow:2 inComponent:0 animated:YES];
[self.view addSubview: _Categories];
_dataArray = [[NSMutableArray alloc] init];
[_dataArray addObject:#"One"];
[_dataArray addObject:#"Two"];
[_dataArray addObject:#"Three"];
[_dataArray addObject:#"Four"];
[_dataArray addObject:#"Five"];
_categoriesData = _dataArray;
_Categories.dataSource = (id)self;
_Categories.delegate = (id)self;
}
- (int)numberOfComponentsInPickerView:(UIPickerView *)Categories
{
return 1;
}
// The number of rows of data
- (NSInteger)Categories:(UIPickerView *)Categories numberOfRowsInComponent:(NSInteger)component
{
return _categoriesData.count;
}
// The data to return for the row and component (column) that's being passed in
- (NSString*)Categories:(UIPickerView *)Categories titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [_categoriesData objectAtIndex:row];
}
Sorry if that's a little too much to read. The point is that in the final portion, when - (NSInteger)Categories:(UIPickerView *)Categories numberOfRowsInComponent:(NSInteger)component is run, it returns a "NSInvalidArgumentException". I tried reinitializing the dataArray and categoriesData in each method, to no avail. I'm not sure what I should do... please help. Thanks!
EDIT:
Found the error. It was in the method call... instead of specifying which UIPickerView I was trying to access, I instead should have just put in a generic "UIPickerView". So, it should've looked like this:
- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{}
and not like this:
- (NSString*)pickerView:(UIPickerView *)Categories titleForRow:(NSInteger)row forComponent:(NSInteger)component
- (NSInteger)pickerView:(UIPickerView *)Categories numberOfRowsInComponent:(NSInteger)component{}
Hope this helps anyone finding a similar problem.
It looks like categoriesData is not assigning the value properly. Try to change this line below and check:-
self.categoriesData = _dataArray;
Related
I'm trying to add a UIPicker to a UITextView when it is selected to choose an age. I found a previous thread and trued to implement the code but I can't get it to work properly. When I build the program the picker shows up, but there are no values in it. Any ideas as to what I'm doing wrong? Also, I'm getting two yellow errors here saying "Assigning to 'id' from incompatible type 'ViewController *const __strong" here:
pickerView.delegate = self;
pickerView.dataSource = self;
Thank you.
#interface ViewController ()
#property (weak, nonatomic) IBOutlet UITextField *ageTextField;
#end
#implementation ViewController
#synthesize ageTextField;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIPickerView *pickerView =[[UIPickerView alloc]init];
pickerView.delegate = self;
pickerView.dataSource = self;
pickerView.showsSelectionIndicator=YES;
ageTextField.inputView=pickerView;
}
- (void)pickerView:(UIPickerView *)PickerView
didSelectRow:(NSInteger)row
inComponent:(NSInteger)component {
NSMutableArray *ageArray = [[NSMutableArray alloc]init];
[ageArray addObject:#"1"];
[ageArray addObject:#"2"];
[ageArray addObject:#"3"];
[ageArray addObject:#"4"];
ageTextField.text=[ageArray objectAtIndex:row];
}
#interface ViewController () <UIPickerViewDataSource, UIPickerViewDelegate>
#property (strong, nonatomic) UIPickerView *pickerView;
#property (strong, nonatomic) NSArray *pickerElements;
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.pickerView = [[UIPickerView alloc] init];
self.pickerView.delegate = self;
self.pickerView.dataSource = self;
self.pickerView.showsSelectionIndicator = YES;
self.ageTextField.inputView = self.pickerView;
self.pickerElements = #[#"text1", #"text2", #"text3", #"text4"];
[self pickerView:self.pickerView
didSelectRow:0
inComponent:0];
}
- (int)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (int)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [self.pickerElements count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [self.pickerElements objectAtIndex:row];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
self.ageTextField.text = [self.pickerElements objectAtIndex:row];
}
#end
Im really close on this one...For the purposes of this i have two text boxes. when pressed they invoke a ui picker.
text box one returns values 1,2,3,4
text box two returns values A, B, C, D
The problem is that when the picker is presented for text box two it shows the values from text box one, although will select the appropriate row from text box two. Could someone check over my code and tell me where im making an error, thanks.
.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate,UITextFieldDelegate>
{
//decalre picker
UIPickerView *select;
//declare NSArrray
NSArray *arrStatus;
NSArray *arrStatus2;
}
#property (strong, nonatomic) IBOutlet UITextField *text1;
- (IBAction)Value:(id)sender;
#property (strong, nonatomic) IBOutlet UITextField *text2;
#end
.m
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize text2;
#synthesize text1;
- (void)viewDidLoad
{
select = [[UIPickerView alloc] initWithFrame:CGRectZero];
select.delegate = self;
select.dataSource = self;
[select setShowsSelectionIndicator:YES];
text1.inputView = select;
text2.inputView = select;
arrStatus = [[NSArray alloc] initWithObjects:#"1",#"2",#"3",#"4",nil];
arrStatus2 = [[NSArray alloc] initWithObjects:#"A",#"B",#"C",#"D",nil];
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
//One column
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
//set number of rows
return arrStatus.count;
return arrStatus2.count;
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
//set item per row
return [arrStatus objectAtIndex:row];
return [arrStatus2 objectAtIndex:row];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setText1:nil];
[self setText2:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)Value:(id)sender {
NSInteger selectedRow = [select selectedRowInComponent:0];
if([text1 isFirstResponder])
text1.text = [arrStatus objectAtIndex: selectedRow];
[text1 resignFirstResponder];
if ([text2 isFirstResponder])
text2.text = [arrStatus2 objectAtIndex: selectedRow];
[text2 resignFirstResponder];
}
#end
So to sum up im trying to get, 1 picker view, with 1 colum, 2 arrays, 2 text boxes. Ive tried creating another picker view and that didnt work either
The return statement exits the method. Therefore , if you have 2 return statements , it will never get to the second one. You should modify these methods as such:
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if([text1 isFirstResponder])
return arrStatus.count;
else
return arrStatus2.count;
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if([text1 isFirstResponder])
return [arrStatus objectAtIndex:row];
else
return [arrStatus2 objectAtIndex:row];
}
Hope this helps. Cheers!
This is Code Which is able to show picker view with the given array and textfield will have the first data of the UIPickerView.Please let me know if you have any issue.I did it for one textfield for next textfield you just need to figure out using tag of textfield and set the Text.
-(void)viewDidLoad
{
[super viewDidLoad];
arrayNo = [[NSArray alloc] initWithObjects:#"1",#"2",#"3",#"4",nil];
[pickerView selectRow:1 inComponent:0 animated:NO];
self.text1.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];
}
Am trying to configure a two component picker, and am getting some errors which I have commented out:
Implementation file:
#import "BIDDoubleComponentPickerViewController.h"
#implementation BIDDoubleComponentPickerViewController
#synthesize doublePicker;
#synthesize fillingTypes;
#synthesize breadTypes;
- (IBAction)buttonPressed:(id)sender
{
NSInteger fillingRow = [doublePicker selectedRowInComponent:kFillingComponent]; // Use of undeclared identifier 'kFillingComponent'
NSInteger breadRow = [doublePicker selectedRowInComponent:kBreadComponent]; // Use of undeclared identifier 'kBreadComponent'
NSString *bread = [breadTypes objectAtIndex:breadRow];
NSString *filling = [fillingTypes objectAtIndex:fillingRow];
NSString *message = [[NSString alloc]initWithFormat:#"Your %# on %# bread will be right up", filling, bread];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Thank you for your order"
message:message
delegate:nil
cancelButtonTitle:#"Great!"
otherButtonTitles:nil];
[alert show];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSArray *fillingArray = [[NSArray alloc] initWithObjects:#"Ham", #"Turkey", #"Peanut Butter", #"Tuna Salad", #"Chicken Salad", #"Roast Beef", #"Vegemite", nil];
self.fillingTypes = fillingArray;
NSArray *breadArray = [[NSArray alloc] initWithObjects:#"White", #"Whole Wheat", #"Rye", #"Sourdough Bread", #"Seven Grain", nil];
self.breadTypes = breadArray;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.doublePicker = nil;
self.breadTypes = nil;
self.fillingTypes = nil;
}
#pragma mark - View lifecycle
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark -
#pragma mark Picker Data Source Methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 2;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (component == kBreadComponent) { // Use of undeclared identifier 'kBreadComponent'
return [self.breadTypes.count]; // Expected identifier
return [self.fillingTypes objectAtIndex:row]; // Use of undeclared identifier 'row'
}
}
#pragma mark Picker Delegate Methods
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (component == kBreadComponent) { // Use of undeclared identifier 'kBreadComponent'
return [self.breadTypes objectAtIndex:row];
return [self.fillingTypes objectAtIndex:row];
}
}
#end
Interface file:
#import <UIKit/UIKit.h>
#interface BIDDoubleComponentPickerViewController : UIViewController
<UIPickerViewDelegate, UIPickerViewDataSource>
#property (strong, nonatomic) IBOutlet UIPickerView *doublePicker;
#property (strong, nonatomic) NSArray *fillingTypes;
#property (strong, nonatomic) NSArray *breadTypes;
- (IBAction)buttonPressed:(id)sender;
#end
kBreadComponent and kFillingComponent are not declared anywhere. If they're declared in a header (.h) file, you need to #import it.
Your numberOfRowsInComponent and titleForRow methods are similar, and they are wrong: they have two consequent unconditional return, and this means that the second one will never be executed.
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return self.breadTypes.count;
}
#pragma mark Picker Delegate Methods
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (component == kBreadComponent) {
return [self.fillingTypes objectAtIndex:row];
}
return nil; // Or something, empty string for example. Method requires to return a NSString, so you have to return at least nil;
}
Still you have to find kBreadComponent and kFillingComponent and #import the file with the definitions of them.
I have a plist that is being loaded into a UIPickerView. I can access the array info and have it loaded into the picker in one of the components. What I'm trying to do is to access Item 0 or Item 1 and have them displayed on a UILabel based on a condition.
I can't figure out how to access Item 0 or Item 1 (the string values). Any tips on how I'd go about doing this? thanks for the help.
here's an image to clarify what I'm talking about:
pickerViewcontroller.h
#import <UIKit/UIKit.h>
#define kStateComponent 0
#define kZipComponent 1
#interface PickerViewController : UIViewController
<UIPickerViewDataSource,UIPickerViewDelegate>{
IBOutlet UIPickerView *dpicker;
NSDictionary *stateZip;
NSArray *states;
NSArray *zips;
}
#property (nonatomic,retain) UIPickerView *dpicker;
#property (nonatomic,retain) NSDictionary *stateZip;
#property (nonatomic, retain) NSArray *states;
#property (nonatomic, retain) NSArray *zips;
#end
pickerViewcontroller.m
#import "PickerViewController.h"
#implementation PickerViewController
#synthesize dpicker;
#synthesize stateZip;
#synthesize states;
#synthesize zips;
-(void) viewDidLoad{
NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath =[bundle pathForResource:#"plistfilename" ofType:#"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
self.stateZip=dictionary;
[dictionary release];
NSArray *component = [self.stateZip allKeys];
NSArray *sorted =[component sortedArrayUsingSelector:#selector(compare:)];
self.states=sorted;
NSString *selectedState = [self.states objectAtIndex:0];
NSArray *array = [stateZip objectForKey:selectedState];
self.zips = array;
}
#pragma mark -
#pragma mark Memory management
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
// For example: self.myOutlet = nil;
}
- (void)dealloc {
[dpicker release];
[stateZip release];
[states release];
[zips release];
[super dealloc];
}
#pragma mark-
#pragma mark picker Data Source Methods
-(NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerview
{
return 2;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (component == kStateComponent)
return [self.states count];
return [self.zips count];
}
#pragma mark picker delegate Methods
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
if(component == kStateComponent)
return[self.states objectAtIndex:row];
return [self.zips objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if(component == kStateComponent)
{
NSString *selectedState = [self.states objectAtIndex:row];
NSArray *array=[stateZip objectForKey:selectedState];
self.zips=array;
[dpicker selectRow:0 inComponent:kZipComponent animated:YES];
[dpicker reloadComponent:kZipComponent];
}
}
#endhere
I'm having 2 UIPickerViews and two UILabels in my view and the UIPickerViews are populated with numbers from an NSMutableArray.
The pickers need to send there chosen value to there assigned label. Example:
_pickerView1 (selected "18")
_pickerOutputLabel1 (shows "18")
_pickerView2 (selected "7")
_pickerOutputLabel2 (shows "7")
I can't get this working, _pickerView2 also sends its value to _pickerOutputLabel1 instead of _pickerOutputLabel2.
I've tried a couple of things but i can't figure out how to get it to work.
This is the code (i removed my attempts to fix the issue so it atleast compiles :)
//header file
#import <UIKit/UIKit.h>
#interface UIPickerViewAndLabelsViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> {
NSMutableArray *nrArray;
IBOutlet UIPickerView *_pickerView1;
IBOutlet UIPickerView *_pickerView2;
UILabel *_pickerOutputLabel1;
UILabel *_pickerOutputLabel2;
}
#property (nonatomic, retain) IBOutlet UIPickerView *pickerView1;
#property (nonatomic, retain) IBOutlet UIPickerView *pickerView2;
#property (nonatomic, retain) IBOutlet UILabel *pickerOutputLabel1;
#property (nonatomic, retain) IBOutlet UILabel *pickerOutputLabel2;
#end
//implementation file
#import "UIPickerViewAndLabelsViewController.h"
#implementation UIPickerViewAndLabelsViewController
#synthesize pickerView1 = _pickerView1;
#synthesize pickerView2 = _pickerView2;
#synthesize pickerOutputLabel1 = _pickerOutputLabel1;
#synthesize pickerOutputLabel2 = _pickerOutputLabel2;
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
// Implement loadView to create a view hierarchy programmatically, without using a nib.
/*
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
_pickerOutputLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(400, 120, 50, 50)];
[self.view addSubview:_pickerOutputLabel1];
_pickerOutputLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(400, 320, 50, 50)];
[self.view addSubview:_pickerOutputLabel2];
nrArray = [[NSMutableArray alloc] init];
for (int i=0;i<20+1;i++) {
[nrArray addObject:[NSString stringWithFormat:#"%d", i]];
}
_pickerView1 = [[UIPickerView alloc] initWithFrame:CGRectMake(500, 120, 100, 162)];
_pickerView1.delegate = self;
_pickerView1.dataSource = self;
_pickerView1.showsSelectionIndicator = YES;
_pickerView1.transform = CGAffineTransformMakeScale(0.8, 0.8);
[self.view addSubview:_pickerView1];
[_pickerView1 release];
[_pickerView1 selectRow:0 inComponent:0 animated:NO];
_pickerOutputLabel1.text = [nrArray objectAtIndex:[_pickerView1 selectedRowInComponent:0]];
_pickerView2 = [[UIPickerView alloc] initWithFrame:CGRectMake(500, 320, 100, 162)];
_pickerView2.delegate = self;
_pickerView2.dataSource = self;
_pickerView2.showsSelectionIndicator = YES;
_pickerView2.transform = CGAffineTransformMakeScale(0.8, 0.8);
[self.view addSubview:_pickerView2];
[_pickerView2 release];
[_pickerView2 selectRow:0 inComponent:0 animated:NO];
_pickerOutputLabel2.text = [nrArray objectAtIndex:[_pickerView2 selectedRowInComponent:0]];
[super viewDidLoad];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)_pickerView1;
{
return 1;
}
- (void)pickerView:(UIPickerView *)_pickerView1 didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
_pickerOutputLabel1.text= [nrArray objectAtIndex:row];
}
- (NSInteger)pickerView:(UIPickerView *)_pickerView1 numberOfRowsInComponent:(NSInteger)component;
{
return [nrArray count];
}
- (NSString *)pickerView:(UIPickerView *)_pickerView1 titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
return [nrArray objectAtIndex:row];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (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
I'm trying for 3 days and i'm stuck.
Thanks in advance.
In the UIPickerView delegate methods, you've named the pickerView parameter "_pickerView1". Naming that parameter the same as the instance variable does not mean the delegate method will be called only for that picker. It just becomes the local name for whatever picker calls the delegate method.
Since you've set the delegate for both the pickers to be self, both the pickers call the same methods.
To tell which picker is making the call, a couple of ways are:
Set a different tag value for each one when creating them and check the tag in the delegate method (eg. _pickerView1.tag = 1; and in the delegate method: if (pickerView.tag == 1)... )
Or, compare directly against the instance variable. For example:
- (void)pickerView:(UIPickerView *)pickerView //<-- std name as in doc
didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (pickerView == _pickerView1)
// Above:
// "pickerView" is the picker in which a row was selected
// "_pickerView1" is the actual instance variable
_pickerOutputLabel1.text = [nrArray objectAtIndex:row];
else
_pickerOutputLabel2.text = [nrArray objectAtIndex:row];
}
Also, you have IBOutlet in front of the control declarations but then you create them programmatically. If you are using Interface Builder to create the controls, don't re-create them in code. If you're not using IB, remove the IBOutlet.
you can also use this:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if( [pickerView isEqual: picker ]){
firststr = [firstArray objectAtIndex:row];
}
if( [pickerView isEqual: pickerAnother ]){
secondstr = [secondArray objectAtIndex:row];
}
}