handle clicks to UIPickerView rows - iphone

I handle clicks to UIPickerView rows with a regular method
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
but it works only for non-current rows. My problem is that I need to get taps on the already selected (current) row also. Any ideas or workarounds for didSelectRow? Thanks.

You could put a clear button over each row and handle touches from it like any other button.

Related

How to get the event when a picker view stopped scrolling

I need to perform some code when the user stop scrolling the picker, in other way, when the picker stop scrolling. The logic i want to follow is, once the picker stop scrolling, i get the current value and i do some database queries basing on that value.
In the picker view documentation, i don't see a delegate method that can help on such task. Any thoughts? thanx in advance.
whenever you scroll the picker view, didSelect delegate method call at the end of scroll
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSLog(#"Selected %i. ", row);
/// do it here your queries
}
try with above example and check your console
The delegate class has a method pickerView:didSelectRow:inComponent:, that you can use to detect the selected row.

Apple App UIPicker - how to make a multiple UIPicker?

I want to make multiple UIPicker with following requirements -
Make Multiple UIPicker (let's call them Picker1 and Picker2)
Value of Picker2 should automatically change based upon value of Picker1 (for instance I Picker1 has countries and Piker2 should display cities in that country)
also I would like to change the data in UIView based upon the value selected from Picker1 and Picker2 (lets say we select "UK" and city as "London" then UIView should talk only about "places to visit in london"
I know it sounds like lot of asking - your help would be highly appreciated, Thanks in advance.
First, your ViewController(the one with the picker) should implement the UIPickerViewDelegate.
You should than use this method:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
It gets called every time you change a the selected row on any of the components of your picker.
For example when this gets called, you should change the UIView element to the appropriate value.
This is also the moment to reload Component2 (or whatever you want to call it) of your picker like this.
[picker reloadComponent:2];
or
[picker reloadAllComponents];

Button click event and picker view object firing

I need to know how to firing picker object after I click a button. So i need to know how to do that one.
Have you implemented UIPickerViewDelegate didSelectRow delegate method,
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

Iphone UIView implementation

How does one code this scenerio in iphone sdk?
In an expense app, when you want to add an expense, this view comes up.
After selecting "Clothing," another view slides up with a UIPickerView control that has a "done" button which will dismiss the UIPickerView. Below is a screen shot after hitting "Clothing."
I'm trying to figure out how one would slide up the UIPickerView half way up the screen with a "done" button on top of the "New Expense" view?
thank you in advance!
Use CoreAnimation and make the UIView with move from bottom to top.. and change the hidden property to true from false when required and vice versa..
Multiple UIViews can be nested as required take advantage of this to achieve what u need
You implement the UIPickerDelegate, then implement the methods that belongs to the UIPickerView.
So your interface file must contain this:
#interface YourViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> {
Your viewController them implements these, or more, methods:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
t´You would then instantiate the picker, set its delegate and all other properties you need it to conform to.
You could then hook up a "listener" for keeping track on when it changed.
[datePicker addTarget:self action:#selector(didChangeDate) forControlEvents:UIControlEventValueChanged];
A good place to start is the UICatalog example from the Apple developer site.
This has a lot of Picker code and a bunch of other stuff that could help getting in the mindset Apple uses for building stuff with UIElements.
Hope it helps:) it is a large subject.
This post helped me; might help others: http://sdhillon.com/animated-uipickerview

UIPickerView as a Subview

I am trying to create a Dialog Box in which contains a UIPickerView. I can get it to work without the Subview tied around it but I always end up with an Uncaught error. Any help?
Well apparently I fixed by messing with this method -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component