0
votes

In my tableview, I load a custom cell from a nibFile:

        customCell = (cellReponseCircuit *) [tableView dequeueReusableCellWithIdentifier:@"cell"];

        if(!customCell)
        {
            customCell = [[[NSBundle mainBundle] loadNibNamed:@"cellReponse" owner:self options:nil]lastObject];
        }

        customCell.reponse.text = [[langue singletonLangue] mot:@"Entrer votre réponse ici"]; 

        cell = [customCell retain];

and I subClass UITableViewCell:

@interface cellReponseCircuit : UITableViewCell {

IBOutlet UITextField *reponse;
IBOutlet UISegmentedControl *segVraiFaux;

}

@property(nonatomic,retain) IBOutlet UITextField *reponse; @property(nonatomic,retain) IBOutlet UISegmentedControl *segVraiFaux;

@end

But I don't where to put UiTextFieldDelegate. Because If I put it in the cell class it don't works, and if I put I in the tableViewController it don't works.

2
First, I find the way you load your cell very unclean. You use a lot of side-effects here. Why don't you put that cell directly into the nib file of the view controller? Second, I don't understand what don't works here. Maybe you could be a bit more specific... - Max Seelemann
I want to use the call - (void)textFieldDidBeginEditing:(UITextField *)textField, but this method is not called - alex

2 Answers

0
votes

Ok It's because the link beetween the file owners and the textfield delegate was not did in IB, now it works.

0
votes

You can give tag to each reponse property of the cell and set the tableViewController as the delegate

customCell = (cellReponseCircuit *) [tableView dequeueReusableCellWithIdentifier:@"cell"];

    if(!customCell)
    {
        customCell = [[[NSBundle mainBundle] loadNibNamed:@"cellReponse" owner:self options:nil]lastObject];
    }

    customCell.reponse.text = [[langue singletonLangue] mot:@"Entrer votre réponse ici"]; 
    customCell.reponse.tag = indexPath.row;
    customCell.reponse.delegate = yourTableViewController; 

    cell = [customCell retain];

In the UITextField delegate methods you can get the particulate reponse property of your cell class by the given tag