查找选择器视图选择何时发生变化?
当用户更改选择器视图中的选定行时,有什么方法可以让对象接收消息吗?我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用
- (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 andcomponent
tells you which component it's in.Remember to include
<UIPickerViewDelegate>
in your header file.UIPickerView 有一个可以使用的委托,称为 UIPickerViewDelegate。其中,有一个名为:的方法,
它可以让您知道他们选择了哪一行以及在哪个组件中,并且如果我理解正确的话,应该完成您所要求的任务。
UIPickerView has a delegate that you can use, called UIPickerViewDelegate. In it, there is a method called:
That lets you know what row they've selected and in what component, and should accomplish what you're asking, if I understood correctly.
怎么样:
它是 UIPickerView 的委托之一。
What about:
It's one of UIPickerView's delegates.
您可能想查看 < code>UIPickerViewDelegate Protocol
特别是您可能会对以下消息感兴趣:
You might want to have a look at the
UIPickerViewDelegate Protocol
Especially the message might be interesting to you: