Custom UIPickerView to have unselectable first row - iphone

I'd like to create a custom UIPickerView in iOS that will present the elements of the picker to the user, but have a "blank" selection at the top. If the user doesn't select anything then the result from the UIPickerView is nil. If the user scrolls down to select something, then it just returns to proper index in the list.
The problem with the UIPickerView is that when you come into it, it looks like the user has at least selected the first element.
I would like to "force" the user to pick something.
Thanks for your help.

can't you just make the first item in the datasource a #""?

Related

help needed for combo box in iphone

Please help me to create drop down box using iphone. I tried in pickerview with textfield but not worked as my requirement can u suggest the url for to solve this problem. The data should come from xml and as a select option in html.
The easiest way is to use a UITableView with the options, which upon selecting a cell, returns the value of that cell to whatever control that has the select.
For the select you can use a button with a custom image for example, and show a table using presentModelViewController.
When the TableView shows and a selection is made, you store the selected value and dismiss the tableView using dismissModalViewController.
I had the same problem where the Picker just did not fit my requirements and used the tableView solution.

PickerView select first row

I have a UIPickerView that pops up from the bottom of the IPhone's screen when a UITextField begins editing. When a row is selected my UIPickerView is dismissed.
But the problem is that don't manage to select the first row which is shown under the selection indicator.
Right now I can select all except the first row. So the UIPickerView never dismisses and I can't choose that value.
The only workaround I found is to scroll a bit the picker in order to still select the first row, so when I "release the touch" the first row is selected. But it's not a good workaround I need the same behavior I have with the other rows.
Thanks for your help as usual.
Wallou
Bye
The way many apps do the trick is to add a button upon the picker to validate the selected item.

UIPickerView row selection

I have a UIPickerView with two components.
It works fine when the user scrolls each component until it reaches the desired value.
But I want it to behave like the picker in the calendar or the clock apps. Meaning: When the user presses a certain value in one of the components, I want that component to automatically turn that row to be the selected row (so the user doesn't always have to scroll, he/she can also simply select the value they want).
Does anyone know how to do that?
Thank you,
~Chonch
It is standard picker behaviour and it should work so automatically.
If your picker does not select tapped row automatically try to set userInteractionEnabled property to NO for the view you return from viewForRow: method in picker data source.

UITextField and UITableViews... Am I doing this correctly? If not, what is the best way?

I have an array of folders. Each folder is listed as a table view row.
When I display my table, I populate it with a set of textfields on the left hand side of the row (i want the user to be able to edit them) and a set of switches (on/off) on the right hand side of the row.
All is working well, you can touch the textfield and the keyboard appears. You can changed the values of the switch each time also.
The problem I'm having is knowing which text field has been changed so that I can update my array ready to save the values.
I'm using..
[textField addTarget:self action:#selector(textFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit];
and...
-(void)textFieldDone:(UITextField *)textField
The problem is that the textField object does not contain any unique information about it in the textFieldDone selector. I've tried setting
[textField setTag:rowNumber];
But it doesn't show as tag is not part of the textField object.
Anyone any ideas on the best way of doing this? Surely there must be lots of applications that have have textfields in table rows that you can switch between?
Or maybe I'm missing something here....
Actually 'tag' is part of the UITextField as it is inherited from UIView.
Maybe I can suggest a different approach. Use your table view to display the data with a checkmark in the accessory view if the boolean value you are representing with a switch currently is set to YES. When the user taps that row, push a new view controller that contains a text field and a switch that the user can edit.
Is there an application you've seen that uses the UI method your attempting with the text field and switch in a table cell?
Keep in mind that you are probably reusing table cells, which is what you're supposed to do, however you may not be setting the tag on subsequent uses of that cell. Just guessing here.

How mimic delete specific row in a UITableView?

I have a list of things in a table view.
When a user tap a row, I increase score. I wish provide a way to clear the score for that row.
My first try is put the table in edit mode, show the delete button to that row and proceed. However, all the other rows get blocked and can't tap again the score or tap in the disclosure button.
So, obviously this is not the way. But then I don't see what to do. Any suggestion?
You could add a button to clear the row’s score as a subview of your table cell. I suppose you’d have to put it on the left side, though, since the disclosure button is on the right.