I am trying to add in a third method into the editting view controller in this example; a simple pickerview for a field. Currently, my pickerview has 6 items that I load into it. When I run it, it shows a '?' for the value on the picker view rather than t开发者_JS百科he word. It does select the right item/row and return it to the calling controller, but it just won't display the text.
I believe that I am not allocating the array properly to the PickerView as it compiles with the following warning:
"Incompatible Objective-C types assigning 'Struct NArrary *', expected 'struct UIPickerView *'"
Here is what I have declared in the .h file:
UIPickerView *pickerView;
NSArray *choiceArray;
@property (nonatomic, retain) IBOutlet UIPickerView *pickerView;
@property (nonatomic, retain) NSArray *choiceArray;
And in the .m file:
choiceArray = [[NSArray alloc] initWithObjects:@"Financial",@"One",@"Two",@"three",@"four",@"six", nil];
pickerView = choiceArray; //<-- error
[choiceArray release];
It's this line: "pickerView = choiceArray;" that I get the warning on.
thx, wes
You are assigning the array to the pickerView attribute itself. Your are doing this:
(UIPickerView*)pickerView = (NSArray*)choiceArray;
You actually assign the rows of a picker view from its delegate which is an object that implements the UIPickerViewDelegate protocol.
精彩评论