I have a UIPickerView
with values 0...250. There is 2 Components in UIPickerView
. In First component i am displaying these values. but i want to detect scrolling method of the UIPickerView
. because when pickerView appears the value I would like to display is 75. means pickerView is scroll to row number 75. and user can scroll up and down the picker with values 0...250.
I have tried this code in UIPickerView
titleForRow row: Int
method
pickerView.selectRow(75, inComponent: 0, animated: true)
in this case when pickerView appears the selected value is 75. Below is exactly what i want
but the problem is that on scrolling pickerView
my app crash with following error
[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
anyone help me please thanks in advance :-)
While inside the
viewDidLoad
method, your picker is empty. You can do this if you delay execution of the select call until after the data is finished loading. Likely one cycle will be enough.You can add it in
viewDidAppear
orviewWillAppear