Reputation: 213
I am using custom cell inside tableView
. In that custom cell, there is label
and textField
....this custom cell is being reused to display ten items. I actually want to open a datepicker
on one of the cell's text field but I am not able to understand that how this work can be achieved?
Upvotes: 1
Views: 73
Reputation: 1055
Please set the text field tag and delegate in cellForRowAtIndexPath method... like..
cell.yourTextFieldName.tag = 1000;
cell.yourTextFieldName.delegate = self;
In .h file add the UITextFieldDelegate
Then in the textFieldShouldBeginEditing delegate you can get the picker.
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
NSInteger txtFldTag = textField.tag;
if(txtFldTag == 1000){
//write the method to show picker.
return NO;
}
Upvotes: 0
Reputation: 3536
All you need to do is to create an instance of UIDatePicker
and set it as inputView
of one of your text fields. When the text field is tapped UIKit will animate appearance of the picker for you. In turn, you'll have to handle user's input and update the text field's text.
Upvotes: 1