我想用 UIPickerView 扩展 CoreDataBooks 示例
在本例中,我尝试将第三种方法添加到编辑视图控制器中;一个简单的字段选择器视图。目前,我的 pickerview 有 6 个项目加载到其中。当我运行它时,它显示一个“?”用于选择器视图上的值而不是单词。它确实选择了正确的项目/行并将其返回到调用控制器,但它只是不会显示文本。
我相信我没有将数组正确分配给 PickerView,因为它编译时出现以下警告:
"Incompatible Objective-C types assigning 'Struct NArrary *', expected 'struct UIPickerView *'"
这是我在 .h 文件中声明的内容:
UIPickerView *pickerView;
NSArray *choiceArray;
@property (nonatomic, retain) IBOutlet UIPickerView *pickerView;
@property (nonatomic, retain) NSArray *choiceArray;
在 .m 文件中:
choiceArray = [[NSArray alloc] initWithObjects:@"Financial",@"One",@"Two",@"three",@"four",@"six", nil];
pickerView = choiceArray; //<-- error
[choiceArray release];
这是这一行:“pickerView = choiceArray;” 我收到警告。
谢谢, 韦斯
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 the 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在将数组分配给 pickerView 属性本身。您正在这样做:
您实际上从其委托中分配选取器视图的行,该委托是一个实现 UIPickerViewDelegate 协议。
You are assigning the array to the pickerView attribute itself. Your are doing this:
You actually assign the rows of a picker view from its delegate which is an object that implements the UIPickerViewDelegate protocol.