이 문제를 검색 한 후 나는 이것을 할 수 있었다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"InsertMarksCell";
SaveAllExamMarksForAllStudentsTableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
StudentPersonalInfo *newStudentName = feedItemsNow[indexPath.row];
myCell.txtStudentMark.text = @"hello";
myCell.txtStudentMark.delegate = self;
myCell.txtStudentMark.tag = indexPath.row;
return myCell;
}
이 코드는 텍스트 필드 "txtStudentMark"델리게이트를 설정하고 태그를 설정합니다.
-(void) textFieldDidEndEditing: (UITextField * ) textField
{
NSString *text = [(UITextField *)[self.view viewWithTag:55] text];
NSLog(@"%@",text);
}
NSLog 함수를 사용하여 계속 null 값을 얻습니다.
사용자가 데이터로 채울 사용자 지정 셀에 textField가 있고 모든 텍스트 필드에서 모든 데이터를 가져와야합니다. 올바른 방향으로 가고 있습니까?
내가 이해 한 것에서 textField에 대한 태그를 설정하고 위임으로 설정해야합니다. 그러면 태그로 textfield를 호출하여 텍스트를 가져올 수 있습니다.
이 작업을 어떻게 할 수 있습니까?
왜 사용하지 않습니까
-(void) textFieldDidEndEditing: (UITextField * ) textField
{
NSString *text = [textField text];
NSLog(@"%@",text);
}
?
문제는 텍스트 필드를 셀에 추가하고 있지만이 태그에 대한보기를 요청한다는 것입니다.
편집하다:
tableview에서 텍스트 필드를 얻으려면
-(void) textFieldDidEndEditing: (UITextField * ) textField
{
UITableViewCell *cell = [self.view.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:55 inSection:0]];
NSString *text = [(UITextField *)[cell.contentView viewWithTag:55] text];
NSLog(@"%@",text);
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다