2

I have picker view with only one component, and 5 values in the component.

I could get the number of wheels , and values in the component, as below

var picker = window.pickers(); 

UIALogger.logMessage("picker array count: " + picker.length);

var pickerWheels = picker[0].wheels();
var pickerWheelsValues =pickerWheels[0].values();

When i log the statement, like "pickerWheels[0].values()[1]", It does displays the first item.

The issue is, how to tap on it ?

pickerWheels[0].values()[1].tap(); // DOESN'T WORK

Can some one provide some input, how to tap on the picker wheel elements ?

I have tried also implementing the UIPickerViewAccessibilityDelegate and overridden //Set the accessiblity for each component.

- (NSString *)pickerView:(UIPickerView *)thePickerView accessibilityLabelForComponent:(NSInteger)component{
    thePickerView.isAccessibleElement = YES;
    thePickerView.accessibilityLabel= @"label";
    return @"label";
}
Sergey K.
  • 24,894
  • 13
  • 106
  • 174
Senthil
  • 23
  • 4

3 Answers3

1

jki's answer is nearly correct, it should be:

window.pickers()[0].wheels()[0].selectValue("another value");
1

There is a post on O'Reilly that shows one way to interact with pickers (scroll down to the reply posted by 'zpthacker').

Basically it involves calculation of where to tap on the picker to have it go back or forth.

The sample needs to be tweaked a bit in order to work regarding creation of a Point, for instance to the following

var tapLoc = new Object();
tapLoc.x = origin.x+tapWidth;
tapLoc.y = tapHeight+origin.y;
target.tap(tapLoc);
Claus Broch
  • 9,212
  • 2
  • 29
  • 38
  • Hi, Earlier I have tried that but, it fails with the below error message. Exception raised while running script: ReferenceError: Can't find variable: Point var tapLocation = new Point(origin.x+tapWidth, tapHeight+origin.y); <----- Am i missing something ? pls help – Senthil Oct 12 '10 at 11:40
  • Yes, I noticed that too. I have modified my answer, so the point should be created properly (but as an Object) – Claus Broch Oct 12 '10 at 16:31
0

Do you want to test tap on wheel or just select particular value on it?

For the selection of particular value you know (on first wheel of the picker) you can use:

window.pickers()[0].wheels()[0].setValue("another value");
jki
  • 4,617
  • 1
  • 34
  • 29
  • jki, I need this functionality! but this does code not work! Why? Do you have it working fine or it's just an assumption? – Stas Nov 01 '12 at 08:35
  • Works fine for me (but not on DatePickers which are special kind of pickers). – jki Nov 01 '12 at 18:33
  • on data picker there are three wheels for month, date and year. You need to use wheels()[0], wheels()[1], wheels()[2] to select values separately. – fangmobile Mar 06 '15 at 17:54