UITableViewCells에 텍스트 필드가 포함 된 Grouped TableView가 있습니다. 내가 저장 버튼을 누르면UITableViewCell의 UITextView - 태그 문제
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if(indexPath.section < 6) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 10,580, 31)];
textField.tag = indexPath.section + 22;
textField.delegate = self;
[cell.contentView addSubview:textField];
[textField release];
}
return cell;
}
은 그래서, saveItem 방법은 호출됩니다
- (void)saveItem {
NSMutableArray *textFieldArray = [[NSMutableArray alloc] init];
for (int i = 0; i <6; i++) {
[textFieldArray addObject:(UITextField *)[self.view viewWithTag:22+i]];
}
...
}
나는 문제없이 처음 4 TextField의 값을 변경할 수 있습니다. 그들은 또한 저장됩니다,하지만 난 5 또는 6 텍스트 필드의 값을 변경할 때, 내 응용 프로그램 충돌을 그리고 난 오류 얻을 :
응용 프로그램을 종료* 인해 캐치되지 않는 예외 'NSInvalidArgumentException', 이유에 '*을 - [ NSMutableArray insertObject : atIndex :] : 0에서 nil 객체 삽입 시도
제안 사항이 있습니까?
감사합니다. 당신이 저장 버튼을 누를 때 모든 섹션이 표시되지 :
여섯 개의 섹션이 모두 표시됩니까? – Nekto
예, 올바른 값으로 채워집니다. – jussi
새 셀을 만들 때 텍스트 필드를 추가해야합니다. 이미 셀이있는 셀에 텍스트 필드를 추가하는 순간입니다. – jrturton