4

I found that I can't do this by UIAPickerWheel.selectValue(), any idea?

Display Name
  • 4,502
  • 2
  • 47
  • 63
CarmeloS
  • 7,868
  • 8
  • 56
  • 103

2 Answers2

5

you can pass your value in picker like this:

Picker.wheels()[1].selectValue(Your_Value);

in wheels()[1], [1] is your wheel number.

Nate
  • 31,017
  • 13
  • 83
  • 207
skyline
  • 185
  • 2
  • 10
  • yeah, I tried this and it worked, but I just don't understand what this means on the document:"This method is unavailable for UIAPickerWheel objects backed by a UIADatePicker view",from here:http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Reference/UIAPickerWheelClassReference/UIAPickerWheel/UIAPickerWheel.html#//apple_ref/doc/uid/TP40009910 – CarmeloS Sep 13 '12 at 11:20
  • @user465191 for UIDatePicker can't use wheel method if you need to set any date in date picke use this method: [datePicker setDate:yourDate animated:YES]; – skyline Sep 13 '12 at 11:45
  • Well almost. Not with a date. The instruments log shows a wheel with value, "Sep 13, Fri". Using `this.popupWindow().pickers()[0].wheels()[0].selectValue("Sep 12, Thu");` fails with "selectValue requires a valid value." Running the 6.1 iPad simulator. Note that this is about manipulating the date picker in UIAutomation, not at all about Objective-C application UI code. – Douglas Lovell Sep 18 '13 at 16:13
1

I have had difficulty using the UIAPickerWheel selectValue function on a picker with date month and day, as shown on the first (leftmost, zero index) wheel from the image below. The only solution that has worked for me, not optimal, is to tap some specified number of times above (below) the current selected value. The following code will tap above the selected value to decrement the date daysAgo times.

var datePicker = this.popupWindow().pickers()[0];
for (var i = 0; i < daysAgo; ++i) {
    datePicker.wheels()[0].tapWithOptions({tapOffset:{x:0.81, y:0.30}});
    this.target().delay(.4);
}

enter image description here

Douglas Lovell
  • 1,549
  • 17
  • 27