Does UIPickerView's selectRow:inComponent:animated: call pickerView:didSelectRow:inComponent:?

帅比萌擦擦* 提交于 2019-11-30 17:42:56

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];

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

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)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!