Search code examples
iphonerowuipickerviewuipickerviewcontroller

Row for pickerview titleForRow always start from 2


I'm using UIpickerview in my app. The problem is that my pickerview titleforrow function always return 3 rows although numberofRowsinComponent return more rows.

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:
    (NSInteger)component {

return [filteredTerms count]; }


- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:
    (NSInteger)row forComponent:(NSInteger)component {


CreateOrder *order =  [filteredTerms objectAtIndex:row];

NSString *title;
title = order.kBranchName;

return title;   }   

I've even tried to hard code the number or rows returned, but it is not working. The titleforrow row always start from 2.


Solution

  • Try this

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