查找选择器视图选择何时发生变化?

发布于 2024-11-29 13:00:01 字数 162 浏览 2 评论 0原文

当用户更改选择器视图中的选定行时,有什么方法可以让对象接收消息吗?我的 pickerview 有两个组件,当用户点击屏幕一次时它就会被关闭。但我需要根据第一个组件中选择的选项将第二个组件中的某些选项灰显。

另一种选择是使用定时函数定期检查选择了哪一行,但这确实很麻烦。我可以使用任何委托函数吗?

Is there any way I can have an object receive a message when the user changes the selected row in the picker view? My pickerview has two components and it is dismissed when the user taps the screen once. But I need to gray out certain options in the second component depending on which option in the first component is chosen.

One other option is to use a timed function to periodically check which row is selected, but that's really hacky. Are there any delegate functions I can use?

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

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

发布评论

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

评论(4

暖心男生 2024-12-06 13:00:01

使用 - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

row 告诉您它在哪一行,component 告诉您它位于哪个组件。

请记住在头文件中包含

Use - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component.

row tells you what row it is and component tells you which component it's in.

Remember to include <UIPickerViewDelegate> in your header file.

挽清梦 2024-12-06 13:00:01

UIPickerView 有一个可以使用的委托,称为 UIPickerViewDelegate。其中,有一个名为:的方法,

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

它可以让您知道他们选择了哪一行以及在哪个组件中,并且如果我理解正确的话,应该完成您所要求的任务。

UIPickerView has a delegate that you can use, called UIPickerViewDelegate. In it, there is a method called:

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

That lets you know what row they've selected and in what component, and should accomplish what you're asking, if I understood correctly.

狼性发作 2024-12-06 13:00:01

怎么样:

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent

它是 UIPickerView 的委托之一。

What about:

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent

It's one of UIPickerView's delegates.

乖乖 2024-12-06 13:00:01

您可能想查看 < code>UIPickerViewDelegate Protocol

特别是您可能会对以下消息感兴趣:

pickerView:didSelectRow:inComponent:
当用户在组件中选择一行时由选取器视图调用。

You might want to have a look at the UIPickerViewDelegate Protocol

Especially the message might be interesting to you:

pickerView:didSelectRow:inComponent:
Called by the picker view when the user selects a row in a component.

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