0

I have a problem with my UIPickerView. The content isn't displaying on the line.

.m

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

} // End numberOfComponentsInPickerView

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

} // End numberOfRowsInComponent

-(UIView *)pickerView:(UIPickerView *)pickerView
           viewForRow:(NSInteger)row
         forComponent:(NSInteger)component
          reusingView:(UIView *)view
{    
   return [pickerData objectAtIndex:row];   
} 

All the items are connected properly.

What could be the problem?

1 Answers1

1

What kind of data do you have in pickerData? The method you're using (pickerView:viewForRow:forComponent:reusingView:) needs to return a UIView. If pickerData contains strings, then you should be using pickerView:titleForRow:forComponent:.

rdelmar
  • 103,982
  • 12
  • 207
  • 218
  • I changed it to pickerView:titleForRow:forComponent: and i-> return [pickerData objectAtIndex:row]; but the Picker is empty .. Also when i changed it to IOS 6 its working Good . – user3666781 Jun 27 '14 at 07:06
  • Also i found this answer - http://stackoverflow.com/questions/19158319/ios7-uipickerview-doesnt-properly-display-custom-views-with-images But There is Self.myimage --- But all the images are on pilst.com. So how can i pull them ... – user3666781 Jun 27 '14 at 07:17
  • @user3666781 What type of data is in pickerData? – rdelmar Jun 27 '14 at 15:09
  • the type is NSArray- @property (strong, nonatomic) NSArray *pickerData; – user3666781 Jun 28 '14 at 09:02
  • @user3666781 what I asked is what kind of data is *in* dataPicker, not what its type is. Do you have strings in there, images, what? – rdelmar Jun 28 '14 at 14:59