2014-10-21 2 views
0

나는 cell을 가지고 있으며 UITextField입니다. TextField는 셀 전체에 뻗어 있습니다. textField 키를 누르면 키보드가 나타나지만 didSelectItemAtIndexPath이 호출되지 않습니다.UITextField에서 UICollectionViewController/UITableViewController로 터치 이벤트를 전달하는 방법은 무엇입니까?

어떻게 트리거 할 수 있습니까? didSelectItemAtIndexPath은 선택된 셀의 indexPath을 전달합니다. 그게 필요해.

답변

1

cell.textfield.userInteractionEnabled = NO; 

다음 didSelectRowAtIndexPath

MYTextFieldCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 
[cell.textfield becomeFirstResponder]; 
cell.textfield.userInteractionEnabled = YES; 

// code that needs the indexPath 

UITextFieldTextDidEndEditingNotification에 가입 할 내가 그것을 다른 방법으로 주위를 할 거라고 개인적으로

... 그리고 설정

textfield.userInteractionEnabled = NO; 

때 ' 완료 됨

0
forCellAtIndexPath 방법의 첫 번째

이 태그는 이제 텍스트 필드

NSLog(@"IndexPath ....%li",(unsigned long)textField.tag); 
+0

무엇 indexPath.section''약의 태그를 확인하여 셀의 indexpath를 얻을 수 textFieldDidBeginEditing 에

UITextField *txtField=[[UITextField alloc]initWithFrame:CGRectMake(0,0,self.view.width,self.view.height)]; txtField.tag=indexPath.row; txtField.delegate=self; [cell addSubview:txtField]; 

둘째의 UITextField에 추가 필요하지 않으면'textField'를 서브 클래스 화하고 싶지 않습니다. –

관련 문제