Lovely Lovely - 1 month ago 5
Objective-C Question

TextField on Custom Cells

I have a custom cell on a table view .In that custom cell,there is label and text field....this custom cell is being reused to display ten items.I actually want to open a date picker on one of the cell's text field ..but I am not able to understand that how this work can be achieved?

Answer

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;
}