Hello guys,

There's some issue with my UIPickerView controller. The data won't pop up in it. The 'Drum' by itself is visible but empty.

My code is:

- (void)viewDidLoad
{
    [[self navigationController]setToolbarHidden:YES animated:YES];
    [self setItemShow:theItem];
    self.uiPickerViewData=[[[NSMutableArray alloc]initWithObjects:@"One",@"Two", nil]autorelease];
    [super viewDidLoad];
}

And method which will work when button is getting tapped on

- (IBAction)setQuality:(id)sender 
{

    actionSheet=[[UIActionSheet alloc]initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
    [actionSheet setActionSheetStyle:UIActionSheetStyleDefault];

    CGRect pickerFrame=CGRectMake(0, 44, 0, 0);
    qualityPicker=[[UIPickerView alloc]initWithFrame:pickerFrame];
    qualityPicker.dataSource=nil;
    qualityPicker.delegate=self;
    [actionSheet addSubview:qualityPicker];

    [qualityPicker release];

    UIToolbar *toolBar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, actionSheet.bounds.size.width, 44)];
    [toolBar setBarStyle:UIBarStyleDefault];
    [toolBar sizeToFit];

    UIBarButtonItem *spacer=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    UIBarButtonItem *setButton=[[UIBarButtonItem alloc]initWithTitle:@"Set" style:UIBarButtonSystemItemCancel target:self action:@selector(setQualityIntoDB)];
    UIBarButtonItem *cancelButton=[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];

    [toolBar setItems:[NSArray arrayWithObjects:spacer,setButton,cancelButton, nil]animated:NO];
    [spacer release];
    [setButton release];
    [cancelButton release];

    [actionSheet addSubview:toolBar];
    [toolBar release];

    [actionSheet showInView:self.view];
    [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}

-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

- (NSInteger)numberOfRowsInComponent:(NSInteger)component
{
    return [uiPickerViewData count];
}

-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [uiPickerViewData objectAtIndex:row];
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    // Will be properly implemented later

    DBAccess *access=[[DBAccess alloc]init];
    [access closeDataBase];
    [access release];
}

-(void)setQualityIntoDB
{
   // int index;
    DBAccess *access=[[DBAccess alloc]init];
    [access closeDataBase];
    [access release];

}
-(void)cancel
{
    [actionSheet dismissWithClickedButtonIndex:0 animated:YES];
    [actionSheet release];
}

The help is much appreciated. Thank you in advance

self.uiPickerViewData=[[[NSMutableArray alloc]initWithObjects:@"One",@"Two", nil]autorelease];

I would try getting rid of the autorelease in the above line of code and see if it helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.