UITextFieldDelegate of a customcell
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 *repons开发者_JAVA技巧e; @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.
Ok It's because the link beetween the file owners and the textfield delegate was not did in IB, now it works.
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
精彩评论