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

纵饮孤独 提交于 2019-11-30 01:18:14

问题


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

Thanks


回答1:


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



回答2:


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




回答3:


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)


来源:https://stackoverflow.com/questions/7001738/does-uipickerviews-selectrowincomponentanimated-call-pickerviewdidselectrow

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