PDA

View Full Version : 2 picker views




gracejo
Jan 9, 2012, 09:20 PM
how do i place 2 picker views into a page itself?
i tried, 2 picker views is inserted but the objects that i added appears the same. but i coded it differently. did i code wrongly?



-(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 Items :%@, Index of Selected item: %@", [list objectAtIndex:row], row);
//}

-(NSInteger)numberOfComponentsInPickerViewHistory:(UIPickerView *) thePickerViewHistory {
return 1;
}
-(NSInteger)pickerViewHistory:(UIPickerView *) thePickerViewHistory numberOfRowsInComponent:(NSInteger)component
{
return [historyDates count];
}

-(NSString*)pickerViewHistory:(UIPickerView *) thePickerViewHistory titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [historyDates objectAtIndex:row];
}






- (void)viewDidLoad
{
[super viewDidLoad];

list = [[NSMutableArray alloc] init];
[list addObject:@"Temperature"];
[list addObject:@"Humility"];
[list addObject:@"Light"];


historyDates = [[NSMutableArray alloc] init];
[historyDates addObject:@"3 days ago"];
[historyDates addObject:@"2 days ago"];
[historyDates addObject:@"1 day ago"];

}