How could I use 3 PickerViews in the same View? - iphone

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.

Related

remove index from UITableView while searching

I have a UITable in order to search among some data (timezones). My problem is that when the overlay view comes up the index is still shown.
As shown in the image below the "?" character is shown and the index can be enabled. Is it possible to disable it when searching and the overlay is activated? How?
In sectionIndexTitlesForTableView return nil when your search bar is active.
Decrease your height of UITableView from the top
Do you use UISearchDisplayController?
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return (([[self.fetchedResultsController sectionIndexTitles] count] > 5) ? [self.fetchedResultsController sectionIndexTitles]:nil);
}
I show it when i have more than 5 results
Also this is a method of UITableViewDataSource. you need to implement and specify in header you implement ex :
UITableViewController<NSFetchedResultsControllerDelegate, UISearchBarDelegate, UISearchDisplayDelegate>
Are you refreshing the underlying tableview while the search table view is shown?
If you are, try to stop that. I had a similar problem which I was able to solve this way.

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.

UIPickerView disable column

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.

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

tag for UITabBarItem

When I use the this method to initialize a UITabBarItem:
- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag
Do I need to have a distinct tag for each tab bar item, or (since I don't use them) can I simply use the same tag value for all of them?
I'm pretty sure you can just leave them all as 0 or any other number you choose. Every UIView can potentially have a different tag, and Interface Builder sets them all to 0 by default. I haven't run into any problems with this.
From Apple's UITabBarItem class reference:
tag - The receiver’s tag, an integer that you can use to identify bar item objects in your application.
So it looks like it doesn't really matter.