2010-08-25 54 views
0

在我的tableview,我从nibFile加载自定义单元格:UITextFieldDelegate一个customcell

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

和我的子类的UITableViewCell:

@interface cellReponseCircuit:{UITableViewCell的

IBOutlet UITextField *reponse; 
IBOutlet UISegmentedControl *segVraiFaux; 

}

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

@end

但我不往哪里放UiTextFieldDelegate。因为如果我把它放在单元类中,它不起作用,如果我把它放在tableViewController中,它不起作用。

+0

首先,我发现你加载你的细胞**非常**不洁。你在这里使用了很多副作用。你为什么不把那个单元直接放到视图控制器的nib文件中? 其次,我不明白什么在这里不起作用。也许你可以更具体一些... – 2010-08-25 15:24:58

+0

我想使用调用 - (void)textFieldDidBeginEditing:(UITextField *)textField,但是这个方法没有被调用 – alex 2010-08-25 15:29:46

回答

0

好吧这是因为文件所有者和文本字段委托之间的链接没有在IB中做过,现在它可以工作。

0

你可以给标签在小区的每个效应初探属性和设置tableViewController为代表

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

在的UITextField委托方法,您可以通过给定的标签

让你的类的颗粒效应初探财产