Hello,
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.