Search code examples
iphoneioscocoa-touchuipickerview

UIPickerView pickerView:viewForRow:forComponent:reusingView: does not affect below iOS 5.0


My UIPickerView retrieves it's data using the pickerView:viewForRow:forComponent:reusingView: method.

For some reason the method doesn't affect on iOS 4.3 and below.

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{   
    UILabel* label = (UILabel*)view;

    if (view == nil) {
        label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
    }

    label.text = @"Text";

    return label;
}

Solution

  • This guy has made an example where he states that the view should not be autoreleased. http://alisothegeek.com/2009/07/custom-uipickerview-text-formatting/