1
나는 여러 가지 방법으로 사용자가 한꺼번에 편집 할 수있는 매우 가변적 인 테이블 뷰를 가지고 있습니다. 이 셀의 텍스트 필드에서 행을 추가, 삭제 및 이름을 바꿉니다. 지금까지 내가 함께 셀 indexPath를 액세스 한 : 특정 객체가있는 테이블 뷰 셀에 액세스 중 : Superview를 통해 셀에 액세스하는 법적?
-(void)textFieldDidEndEditing:(UITextField *)textField
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:textField.tag inSection:0];
MainCategory *mainCategory = [self.fetchedResultsController objectAtIndexPath:indexPath];
if(textField.text != mainCategory.name){
mainCategory.name = textField.text;
}
self.activeField = nil;
}
그러나이, 삭제 등 재주문 후 문제를 준 지금이 방식으로 작동합니다 :
-(void)textFieldDidEndEditing:(UITextField *)textField
{
//NSIndexPath *indexPath = [NSIndexPath indexPathForRow:textField.tag inSection:0];
// Get the cell in which the textfield is embedded
id textFieldSuper = textField;
while (![textFieldSuper isKindOfClass:[UITableViewCell class]]) {
textFieldSuper = [textFieldSuper superview];
}
UITableViewCell *cell = textFieldSuper;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
MainCategory *mainCategory = [self.fetchedResultsController objectAtIndexPath:indexPath];
if(textField.text != mainCategory.name){
mainCategory.name = textField.text;
}
self.activeField = nil;
}
이 그것을 할 수있는 법적 방법이 있나요 ?
그래, 그건 괜찮습니다. – Martol1ni
예, 문제가 아닙니다. 나는 여러 번 슈퍼 뷰를 사용했다. – santhu
좋아요. 그래서 모든 태그를 없애고 있습니다 ... 문제가 많이 발생했습니다 ... THX! – MichiZH