Search code examples
iphonexcodeuipickerviewuipickerviewcontroller

Trouble with UIPickerView


I'm totally stuck with the UIPickerView. I keep getting the error :

GDB: received signal: "SIGABRT".

2011-07-14 13:35:19.132 MeldStad[677:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView numberOfComponentsInPickerView:]: unrecognized selector sent to instance 0xaac34c0'

I've read some solution on internet but none of them worked for me.. I've also tried more than 1 PickerView tutorial. Don't know what to do know.

Here is the source of the picker methods:

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

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return [pickerData count];
}

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

Solution

  • The error is saying that you setup your UIPicker delegate in the IB to the UIView where you don't have UIPickerDelegate methods

    @interface YourViewController : UIViewController <UIPickerViewDelegate> 
    

    Or you assigned your delegates to a wrong file. Check IB connection settings. Your datasource and delegate should be set to FilesOwner