我想用 UIPickerView 扩展 CoreDataBooks 示例

发布于 2024-10-05 10:13:21 字数 819 浏览 7 评论 0原文

在本例中,我尝试将第三种方法添加到编辑视图控制器中;一个简单的字段选择器视图。目前,我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笨笨の傻瓜 2024-10-12 10:13:21

您正在将数组分配给 pickerView 属性本身。您正在这样做:

(UIPickerView*)pickerView = (NSArray*)choiceArray;

您实际上从其委托中分配选取器视图的行,该委托是一个实现 UIPickerViewDelegate 协议

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文