2011-12-12 4 views
0

내 iPad 응용 프로그램의 UITableViewCell 안에 UITextField가 있습니다. 텍스트를 입력 한 다음 키보드 닫기 버튼을 누르면 텍스트가 저장되지만 키보드를 먼저 닫지 않고 클릭하면 텍스트가 저장되지 않습니다.UITextField 대리자가 작동하지 않습니다.

나는이 코드를 사용하여 textField를 첫 번째 응답자로 사임하려고했지만 행운은 없습니다.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
    for (int it=0; it < [self.clinicalChecklist count]; ++it) 
    { 
     ClinicalChecklistCell *cell = (ClinicalChecklistCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:it inSection:0]]; 
     UITouch *touch = [[event allTouches] anyObject]; 
     if ([cell.col1_singleEntryValue isFirstResponder] && [touch view] != cell.col1_singleEntryValue) { 
      [cell.col1_singleEntryValue resignFirstResponder]; 
     } 
     if ([cell.col2_singleEntryValue isFirstResponder] && [touch view] != cell.col2_singleEntryValue) { 
      [cell.col2_singleEntryValue resignFirstResponder]; 
     } 
     if ([cell.col1_doubleEntryValue_1 isFirstResponder] && [touch view] != cell.col1_doubleEntryValue_1) { 
      [cell.col1_doubleEntryValue_1 resignFirstResponder]; 
     } 
     if ([cell.col1_doubleEntryValue_2 isFirstResponder] && [touch view] != cell.col1_doubleEntryValue_2) { 
      [cell.col1_doubleEntryValue_2 resignFirstResponder]; 
     } 
     if ([cell.col2_doubleEntryValue_1 isFirstResponder] && [touch view] != cell.col2_doubleEntryValue_1) { 
      [cell.col2_doubleEntryValue_1 resignFirstResponder]; 
     } 
     if ([cell.col2_doubleEntryValue_2 isFirstResponder] && [touch view] != cell.col2_doubleEntryValue_2) { 
      [cell.col2_doubleEntryValue_2 resignFirstResponder]; 
     } 
     [super touchesBegan:touches withEvent:event]; 
    } 
} 

답변

0

당신이 단지의 UITextField의 텍스트를 얻을하려는 경우,

[myTextField addTarget:self action:@selector(getText) forControlEvents:UIControlEventEditingChanged]; 
관련 문제