Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

skunkio

macrumors newbie
Original poster
Apr 25, 2010
28
0
Hi all,
how can i do "something" when i touch a pickerview item?
In my app i have a pickerview filled using an array, now, when i touch (select) a specific item i would do another action. I didn't find nothing on google.
Any idea?

Ciao,
stè
 
Hi,
you can look all delegate methods for UIPickerView by typing UIPickerViewDelegate in xcode docs...

the one you need is...
Code:
- (void)pickerView:(UIPickerView *)_pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
}
dont forget to set pickerViews delegate...
 
In my app i have a pickerview filled using an array, now, when i touch (select) a specific item i would do another action. I didn't find nothing on google.
What did you Google for?

Your first stop should probably have been the documentation for UIPickerView, where the Overview includes this:
A UIPickerView object requires the cooperation of a delegate for constructing its components and a data source for providing the numbers of components and rows. The delegate must adopt the UIPickerViewDelegate protocol and implement the required methods to return the drawing rectangle for rows in each component. It also provides the content for each component’s row, either as a string or a view, and it typically responds to new selections or deselections.
(Emphasis mine).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.