I have a UIPickerView, in it's delegate I'm trying to customize the view for a row. I'm using the 3.1 SDK.
So in the delegate I have:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
// view.backgroundColor = [UIColor redColor];
return view;
}
From the apple docs: If the previously used view (the view parameter) is adequate, return that. If you return a different view, the previously used view is released. The picker view centers the returned view in the rectangle for row.
When I run this, my UIPickerView control doesn't have any items in it, and after a short while crashes. When I remove this particular method (which is optional for the delegate), I can see the labels I set via the titleForRow method, and it will no longer crash.
I'm pretty new to cocoa (and cocoa-touch), I'm not sure the view.backgroundColor thing will work, but even when returning the unmodified old view (which I must do anyway for most rows) crashes my app.
Am I doing something wrong?