Xcode:UIPickerView 文本 &查看控制器链接

发布于 2024-12-02 10:04:52 字数 1113 浏览 3 评论 0原文

我在 XCode 中创建了两个视图控制器以及一个 UIPickerView、一个标签、一个文本视图。我想尝试从 UIPickerView 获取数据,因此当应用程序检测到已选择一行时,它会自动将标签设置为 UIPickerView 中该行的值。我还想要某些选定行的某些描述。

请在此处查看我的应用程序的一些屏幕截图,以进一步了解我正在尝试做什么;

1) http://cl.ly/102K3p2v433N0F1c0m2i - 主屏幕

2) http://cl.ly/102K3p2v433N0F1c0m2i - 控制杆被“拉动”后选定的行

3) http://cl.ly/2d1D2D1Z1s0k053Z2C3H - 弹出视图控制器,但标签/描述仍然具有默认值

这是我的代码;

1) (主屏幕) TroubleMakerViewController.h - http://pastie.org/2466793

2) (主屏幕) TroubleMakerViewController.m - http://pastie.org/2466795

3)(结果屏幕)Results.h - http://pastie.org/2466805

4)(结果屏幕)结果.m - http://pastie.org/2466808

有人可以解释为什么标签和描述文本显示默认文本而不是我的内容有设置吗? XIB 文件中的所有内容都正确链接。

I have created two view controllers in XCode along with a UIPickerView, a label, a text view. I wanted to try and get data from the UIPickerView, so when the app detects that a row has been selected, it will automatically set the label to the value of the row in the UIPickerView. I also wanted certain descriptions for certain selected rows.

See some screenshots of my app here to further understand what it is I am trying to do;

1) http://cl.ly/102K3p2v433N0F1c0m2i - main screen

2) http://cl.ly/102K3p2v433N0F1c0m2i - selected row after lever has been "pulled"

3) http://cl.ly/2d1D2D1Z1s0k053Z2C3H - view controller pops up but the label/description still have default values

Here is my code;

1) (MAIN SCREEN) TroubleMakerViewController.h - http://pastie.org/2466793

2) (MAIN SCREEN) TroubleMakerViewController.m - http://pastie.org/2466795

3) (RESULTS SCREEN) Results.h - http://pastie.org/2466805

4) (RESULTS SCREEN) Results.m - http://pastie.org/2466808

Can somebody explain why the label and description text is showing the default text rather than what I have set it to do? Everything is linked up properly in the XIB files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

草莓酥 2024-12-09 10:04:52

您需要实现 UIPickerViewDelegate 方法 pickerView:didSelectRow:inComponent:,如 文档 一旦当前选定的值就会收到通知变化。在此方法中,只需更新标签的文本即可;-)

You need to implement the UIPickerViewDelegate method pickerView:didSelectRow:inComponent: as described in the documentation to be notified as soon as the currently selected value changes. In this method just simply update the text of your label ;-)

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