2010-08-25 60 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委託方法,您可以通過給定的標籤

讓你的類的顆粒效應初探財產