I want to have the same effect as the birthday date setter in the iPhone contacts app. How do I have a modal date picker come up only halfway on the screen.
I want the date picker to be over a UITableView (like in the iphone contacts app). I would like the UITableView to scroll freely behind the date picker (like in the iphone contacts app).
Thanks in advance.
By far, the best way to achieve a date-picker/uipicker keyboard-like is to use the input view property of a textfield:
Build a simple custom UITableViewCell that contains a UITextField (It's important only because the question was about embedding one in a table view)
@interface pickerCell : UITableViewCell
{
UITextField *txtTextField;
UIPickerView* dtpPicker;
}
set the TextField's inputview to be the UIPickerView (Make sure they have both been allocated and initialized first):
txtTextField.inputView = dtpPicker;
You are almost done. Now when the textfield becomes the first responder (the user tapped it), the user will be presented with a picker view. Just fill it with your own values. or use a date picker.
You can set the picker's delegate/datasource to the same cell (if it will always be a birthdate cell) or have the cell's superview load it with data. Whichever choice you make, be sure to update the txtTextField.text on
pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
Good luck! Elad.