2013-01-07 1 views
0

이 코드를 사용하는 경우 UITextFielddelegate 메서드를 호출하지 않습니다. 이 코드에서는 UITableViewUITextField을 추가합니다.uitableview에 텍스트 필드를 추가하면 textfield가 해당 대리자 메서드를 호출하지 않습니다

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

     if (cell == nil) 
     {   
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil]; 
      cell.accessoryType = UITableViewCellAccessoryNone; 

      if (indexPath.row!=7) 
      { 

      [cell.textLabel setTextColor:[UIColor blackColor]]; 
      [cell.textLabel setTextColor:[UIColor blackColor]]; 

      //Creating Lable 

      UILabel *lblText= [[UILabel alloc] initWithFrame:CGRectMake(53, 30, 150, 35)]; 


      [lblText setFont:[UIFont boldSystemFontOfSize:15.0]]; 
      lblText.backgroundColor=[UIColor clearColor]; 

      lblText.textColor=[UIColor blackColor]; 


      lblText.text = [labelArray objectAtIndex:indexPath.row]; 



      //creating a the textField 

      UITextField *txtField = [[UITextField alloc] init]; 
      [txtField setFrame:CGRectMake(50, 56, 220, 31)]; 

      [txtField setBackgroundColor:[UIColor whiteColor]]; 


      [txtField setBorderStyle:UITextBorderStyleRoundedRect]; 
      txtField.delegate=self; 
      [txtField setFont:[UIFont systemFontOfSize:14.0]]; 
      txtField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; 
       txtField.userInteractionEnabled=YES; 
       txtField.enabled=YES;     


      if (indexPath.row==2) 
      { 
       txtField.keyboardType=UIKeyboardTypeNumbersAndPunctuation; 
      } 
      else if(indexPath.row==3) 
      { 
       txtField.keyboardType=UIKeyboardTypeEmailAddress; 

      }else 
       { 

        txtField.keyboardType=UIKeyboardTypeDefault; 

       } 

       if (indexPath.row==6 ||indexPath.row==5) 
       { 
        [txtField setSecureTextEntry:YES]; 
       } 

      txtField.tag=indexPath.row; 
      [cell addSubview:txtField]; 

      [cell addSubview:lblText]; 
     } 
    } 

    return cell; 
} 
+0

.h 파일에서 를 선언했습니다. –

+0

예를 들어, Pramod

답변

0

방금 ​​같은 문제가 발생했습니다. 난 아무데도 유래에 대한 답을 찾을 수 없습니다 때문에, 여기에 나를 위해 일한 내용은 다음과 같습니다

1)있는 UITableViewController 코드에 스토리 보드에서 필드의 출구를 만들기뿐만 아니라

및 2)의 선언 있는 UITableViewController 코드,

내가

3에 있었다)뿐만 아니라 스토리 보드를 통해 위임 콘센트 후크 : 가) 스토리 보드로 이동하여 문제의 UITextField에 클릭 B)를 연결 검사기로 이동 그 UITextField 및 ctl + 델리게이트 플러스 기호 UITableViewControll 끌어 패널 UITextField는 스토리 보드에 존재합니다. (나는 맨 왼쪽의 스토리 보드 개요에서 UITableViewController로 끌었습니다.)

그런 다음, 내 UITableViewController가 모든 UITextFieldDelegate 메소드를 실행했습니다.

관련 문제