2015-08-06 2 views
0

У меня есть серия текстовых полей в ячейках UITableView. Я успешно выполнил сборку таблицы. Но так или иначе делегат текстового поля, например -(void)textFieldDidBeginEditing, не получает вызова. Я разместил код ниже.UITextfield делегат не запускается

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *myCell; 

    if ([indexPath section]==1 && arrBlockFriendsName.count>0) 
    { 
     static NSString *[email protected]"BlockCell"; 
     BlockUsersTableViewCell *cell=(BlockUsersTableViewCell*)[tableView dequeueReusableCellWithIdentifier:identifier]; 

     if (cell==nil) 
     { 
      cell=[[[NSBundle mainBundle]loadNibNamed:@"BlockUsersTableViewCell" owner:self options:nil]objectAtIndex:0]; 
     } 

     cell.imgBlockFriend.image=[UIImage imageNamed:[arrBlockFriendsImage objectAtIndex:indexPath.row]]; 
     cell.imgBlockIcon.image=[UIImage imageNamed:@"user_lock_icon1.png"]; 
     cell.lblBlockFriendName.text=[arrBlockFriendsName objectAtIndex:indexPath.row]; 
     cell.lblBlockFriendPlace.text=[arrBlockFriendsPlace objectAtIndex:indexPath.row]; 

     myCell=cell; 
    } 

    if ([indexPath section]==3) 
    { 
     AgeSliderTableCell *cell=(AgeSliderTableCell*)[tableView dequeueReusableCellWithIdentifier:@"AgeCell"]; 
     //cell.delegate=self; 

     if (cell==nil) 
     { 
      cell=[[[NSBundle mainBundle]loadNibNamed:@"AgeSliderTableCell" owner:self options:nil]objectAtIndex:0]; 
     } 

     [cell.labelSlider setUpperValue:ageUpperValue]; 
     [cell.labelSlider setMinimumValue:18]; 
     [cell.labelSlider addTarget:self action:@selector(updateSliderLabels:) forControlEvents:UIControlEventValueChanged]; 

     myCell=cell; 
    } 

    if ([indexPath section]==4 && arrLocationLabel.count>0) 
    { 
     static NSString *[email protected]"LocationCell"; 

     LocationTableViewCell *cell=nil; 

     if (indexPath.row ==3) 
     { 
      cell=[tableView dequeueReusableCellWithIdentifier:identifierLocation]; 

      cell=[[[NSBundle mainBundle]loadNibNamed:@"LocationTableViewCell" owner:self options:nil]objectAtIndex:1]; 


      [cell.btnSave addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside]; 
     } 

     if(indexPath.row==0 || indexPath.row==1 || indexPath.row==2) 
     { 
      cell=[tableView dequeueReusableCellWithIdentifier:identifierLocation]; 

      cell=[[[NSBundle mainBundle]loadNibNamed:@"LocationTableViewCell" owner:self options:nil]objectAtIndex:0]; 

      cell.lblLocationDetails.text=[arrLocationLabel objectAtIndex:indexPath.row]; 
      cell.txtLocationDetails.delegate=self; 

     } 
       myCell=cell; 
    } 
    myCell.selectionStyle=UITableViewCellSelectionStyleNone; 
    return myCell; 
} 

Любые идеи, которые могут отсутствовать?

+3

сделал и установил делегат для текстового поля .... как 'txtfield.delegate = self' –

ответ

0

Из кода, кажется, как будто вы только установки делегата для текстового поля под названием cell.txtLocationDetails но не для cell.lblBlockFriendName или cell.lblBlockFriendPlace. Вы хотели бы сделать то же самое для них, как и для cell.txtLocationDetails.

+0

Я использовал ярлык и текстовое поле. Я также объявил делегат UItextfield. Ярлык работает отлично. Но делегат текстового поля не получает вызов –

+0

Для любых текстовых полей, которые вы хотите согласовать с протоколом делегирования, вы должны установить делегат для каждого текстового поля. Например, если вы хотите реализовать методы делегирования, такие как '- (void) textFieldDidBeginEditing', вы должны установить делегат для каждого текстового поля, чтобы этот метод вызывал все из них. Поэтому вы должны сделать 'textfield.delegate = self' для каждого текстового поля, которое у вас есть –

+0

@RitwikMisra работает? –

Смежные вопросы