您好,我有一个 View Controller 的 3 个选择器 View 。想象一下 View A。当我从 View A 中选择数据时,这些数据需要去显示选择器 View 的其他 View Controller 。我不知道该怎么做,我试过很多。请让我知道有人知道这个答案。谢谢。
最佳答案
gihanghost,
UIPickerView 有很多委托(delegate)来通知它的状态。
你可以利用的是,
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
//you can access the selected object using the row value
//you must have provided the array as a data source to your pickerView
YourObject *obj = [YourPickerViewArray objectAtIndex:row]
}
当用户滚动浏览 pickerView 选项并且每一行都成为焦点时,将调用此委托(delegate)。
如果您想稍后在您的代码中访问 pickerView 中当前选定的行,您可以使用下面的代码
NSInteger row = [self.yourPickerViewInstance selectedRowInComponent:0];
YourObject *obj = [YourPickerViewArray objectAtIndex:row]
现在您有了选定的对象。将它传递给你想要的任何 View Controller :)
快乐编码:)
关于ios - 有谁知道如何获取选择器 View 的值(value)并将该值发送到 View Controller 的另一个选择器 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37251452/