UIPickerView disable column - iphone

How can i disable UIPickerView column?
I want to disable only one column of picker. Lets say i have picker with 3 column and i want to disable second column.

There are a couple options here.
1) Capture interaction with the second column and override it.
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;
This method can be implemented to simply go back to where it was before the selection. However, they will still be able to interact with the second column.
2) Simply remove the column from the picker.
I believe this is the best option. Have some boolean 'showSecondColumn'. Then, in:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
you can simply check your little flag and return the appropriate number. UIPickerView has a method: reloadAllComponents
Good luck!

It seems there is no way to disable column. I solved(not best solution) like this:
get column as "image" (snapshot)
grayscale "image"
set "image view" user interaction enabled
add "image view" to picker as subview
If there is any better way it would be great.

Related

iOS 5 Picker View update based on selection?

I am working on a project where I want to have a picker view with 3 columns.
In the first column I want the user to select a letter.
Once the letter is selected I want the second column to update with a list of last names that start with that letter. When a last name is selected I want the third column to update with a list of first names who have the selected last name.
Can this even be done? Help!?
Get the letter that they selected using this pickerview delegate method:
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
You could load the next picker at this point but it would be better to populate the next picker when the done button on each picker is selected:
This is a nice SO post that describes how to use picker views very well: Dismissing UIPickerView with Done button on UIToolBar

Set selected row for a given value in UIPickerView iPhone

In my app, I ask a worker to choose a letter from the alphabet (for example A) and the alphabet will have some explications that will appear in a UIPickerView with 3 # rows.
I want my UIPickerView to be display contents based on the indicator that has been chosen by a worker.
How do I do this?
selection. in this case, it means showing the appropriate row in the middle
- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated;
scrolls the specified row to center.
please provide some code so That I can Get What exact issue is

How to get the mins and secs in UIPickerView as in figure?

How can we achieve such type of selected values to be changed with mins and secs in UIPickerView???
First, you use the pickerView:viewForRow:inComponent:reusingView: data source method to return the "00" label. This is actually a bit tricky, since pickerview will alter the frame of this view to fill the row. That means you have to embed your properly positioned view inside another view, and then return that container view instead.
As for the labels, those are simply UILabel objects that have been positioned correctly and added as subviews of the pickerview itself.
And to get them to update correctly, just change their titles in the pickerView:didSelectRow:inComponent: method.
This is exactly what UIDatePicker is doing.
You should implement UIPickerViewDelegate Protocol and UIPickerViewDataSource Protocol.
In method - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component just return needful title.
You can also add delegator on valueChanged event of UIPickerView. And each time your value changed you can reload all visible rows and set labels mins and secs at right positions.
Oooor you can just add subview with 2 UILabels over the black line.
Oooor you can add subview with black gradient line with labels mins and secs.
Then using method : - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component you can set appropriate width of your columns.

How could I use 3 PickerViews in the same View?

How could I use 3 PickerViews in the same View vertically?
(I can't set height..)
Because I try so many times,But it's still no work.
THANKS...
I think you dont need three picker view in any case if you want to show three type items then you can use cthree components in single pickerview.use this datasource method
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView for doing this.

Just numbers in a UIPickerView?

Is there a way to have a UIPickerView just have escalating numbers to infinity?
Haha. Just kidding, but seriously, I want just a bunch of numbers going up, but I don't want to have to hard-code it all.
Thanks in advance!
I'm pretty sure this can be done with some cleverness (a custom integer class that supports arbitrarily large numbers, and periodically "rolling over" to a higher set of numbers once the user has scrolled through all NSIntegerMax rows (i.e. when the user scrolls to row NSIntegerMax you programmatically scroll them back to row 0 and display "row + NSIntegerMax" instead of just "row"). As they scroll through repeatedly you change it to "row + NSIntegerMax * 2", etc.
Obviously you also have to handle them changing directions are some point.
But I suspect that's what fancier than what you're looking to do. In this case you just want to add these lines of code to your View Controller:
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return NSIntegerMax;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [NSString stringWithFormat:#"%d", row];
}
Then double click on the View nib file (the *.xib file) to open it in Interface Builder, and connect the "data source" outlet to the "File Owner" (the View Controller). That will get you as many integers as I could ever imagine someone scrolling to.
Have a look at this question. It is a variation on your problem.
You could just use a UIStepper. I know you asked about UIPicker but do you really need to use that class or were you using it to explain what kind of thing you wanted