UIPickerView 的 selectRow:inComponent:animated: 是否调用 pickerView:didSelectRow:inComponent: ?

发布于 2024-11-28 18:05:17 字数 141 浏览 1 评论 0原文

UIPickerView的selectRow:inComponent:animated:是否调用pickerView:didSelectRow:inComponent:? 不然我自己调用可以吗?

谢谢

Does UIPickerView's selectRow:inComponent:animated: call pickerView:didSelectRow:inComponent:?
Otherwise, can I just call it myself?

Thanks

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

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

发布评论

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

评论(3

诗笺 2024-12-05 18:05:17

您必须手动调用它,并通过委托来完成。

// In this example the UIPickerView object is in a property
...
self.pickerView.datasource = self;
self.pickerView.delegate = self;

// Selects the row in the specified component
[self.pickerView selectRow:0 inComponent:0 animated:NO];

// Manually calls pickerView:didSelectRow:inComponent:
[self pickerView:self.pickerView didSelectRow:0 inComponent:0];

You do have to call it manually and you do it though the delegate.

// In this example the UIPickerView object is in a property
...
self.pickerView.datasource = self;
self.pickerView.delegate = self;

// Selects the row in the specified component
[self.pickerView selectRow:0 inComponent:0 animated:NO];

// Manually calls pickerView:didSelectRow:inComponent:
[self pickerView:self.pickerView didSelectRow:0 inComponent:0];
撧情箌佬 2024-12-05 18:05:17

尽管可以手动调用它,但它不会。

It does not, although it is possible to call it manually.

柒夜笙歌凉 2024-12-05 18:05:17

它也不会使用 swift 调用委托方法,但您也可以手动执行。针对 swift 3swift 4 的决定:

self.pickerView.datasource = self
self.pickerView.delegate = self

self.pickerView.selectRow(0, inComponent: 0, animated: false)
self.pickerView.delegate?.pickerView?(self.pickerView, didSelectRow: 0, inComponent: 0)

It does not call delegate method with swift too, but you can do it manually also. Decision for swift 3 and swift 4:

self.pickerView.datasource = self
self.pickerView.delegate = self

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