설명을 위해 세 개의 텍스트 뷰가 필요한 테이블 뷰가 있습니다. 태그 1000이 포함 된 텍스트보기가 포함 된 프로토 타입 셀을 만들었습니다. 이 텍스트 뷰를 다시 사용하고 싶지만 스크롤 할 때 텍스트 뷰의 텍스트가 변경됩니다.테이블 뷰 내에서 다중 텍스트 뷰 관리
얼마 동안 Faraz는 haider textview의 위치를 취하고 가끔 zaidi가 faraz의 위치를 차지합니다.
나는 그들에게 고유 한 태그를 붙이려고 노력하지만 아직도 나를 돕지는 못한다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellViewIdentifier = nil;
long section = indexPath.section;
UITableViewCell *cell;
if(section == kSocialStatusSection) {
if(indexPath.row < socialResult.socialStatus.count){
cellViewIdentifier = kCheckBoxItemCellViewIdentifier;
cellViewIdentifier = [cellViewIdentifier stringByAppendingString:langAppendString];
cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellViewIdentifier];
[cell setBackgroundColor:[UIColor clearColor]];
SocialStatus * socialStatus = [socialResult.socialStatus objectAtIndex:indexPath.row];
[cell setBackgroundColor:[UIColor clearColor]];
UILabel *titleLabel = (UILabel *) [cell viewWithTag:kTagTitleCellLabel];
// NSMutableDictionary *obj = [socialStatusArray objectAtIndex:indexPath.row];
[titleLabel setText:[LanguageUtilities isEnglishLanguage]?socialStatus.typeNameEn:socialStatus.typeNameAr];
UIButton *checkBox = (UIButton *) [cell viewWithTag:kTagCheckButton];
// checkBox.selected = NO;
if([socialStatus.selected boolValue]) {
checkBox.selected = YES;
}
else{
checkBox.selected = NO;
}
} else {
cellViewIdentifier = kDescriptionCellViewIdentifier;
cellViewIdentifier = [cellViewIdentifier stringByAppendingString:langAppendString];
cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellViewIdentifier];
[cell setBackgroundColor:[UIColor clearColor]];
GCPlaceholderTextView *textArea = (GCPlaceholderTextView *)[cell viewWithTag:kTagDescriptionTextArea];
textArea.placeholder =getLocalizedString(@"Description");
textArea.delegate = self;
textArea.text = @"FARAZ";
}
}
else if(section == kSocialStatusProblems){
if(indexPath.row < socialResult.socialProblems.count){
cellViewIdentifier = kCheckBoxItemCellViewIdentifier;
cellViewIdentifier = [cellViewIdentifier stringByAppendingString:langAppendString];
cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellViewIdentifier];
[cell setBackgroundColor:[UIColor clearColor]];
SocialProblem * socialProblem = [socialResult.socialProblems objectAtIndex:indexPath.row];
UILabel *titleLabel = (UILabel *) [cell viewWithTag:kTagTitleCellLabel];
// NSMutableDictionary *obj = [socialProblemsArray objectAtIndex:indexPath.row];
[titleLabel setText:[LanguageUtilities isEnglishLanguage]?socialProblem.typeNameEn:socialProblem.typeNameAr];
UIButton *checkBox = (UIButton *) [cell viewWithTag:kTagCheckButton];
if([socialProblem.selected boolValue]) {
checkBox.selected = YES;
}else{
checkBox.selected = NO;
}
} else {
cellViewIdentifier = kDescriptionCellViewIdentifier;
cellViewIdentifier = [cellViewIdentifier stringByAppendingString:langAppendString];
cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellViewIdentifier];
[cell setBackgroundColor:[UIColor clearColor]];
GCPlaceholderTextView *textArea = (GCPlaceholderTextView *)[cell viewWithTag:kTagDescriptionTextArea];
textArea.placeholder =getLocalizedString(@"Description");
textArea.delegate = self;
textArea.text = @"Haider";
}
}
else if(section == kProblemTypesSection){
if(indexPath.row < socialResult.socialProblemsTypes.count){
cellViewIdentifier = kCheckBoxItemCellViewIdentifier;
cellViewIdentifier = [cellViewIdentifier stringByAppendingString:langAppendString];
cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellViewIdentifier];
[cell setBackgroundColor:[UIColor clearColor]];
SocialProblemsType * socialProblemType = [socialResult.socialProblemsTypes objectAtIndex:indexPath.row];
UILabel *titleLabel = (UILabel *) [cell viewWithTag:kTagTitleCellLabel];
// NSMutableDictionary *obj = [problemTypeArray objectAtIndex:indexPath.row];
[titleLabel setText:[LanguageUtilities isEnglishLanguage]?socialProblemType.typeNameEn:socialProblemType.typeNameAr];
UIButton *checkBox = (UIButton *) [cell viewWithTag:kTagCheckButton];
if([socialProblemType.selected boolValue]) {
checkBox.selected = YES;
}else
{
checkBox.selected = NO;
}
} else {
cellViewIdentifier = kDescriptionCellViewIdentifier;
cellViewIdentifier = [cellViewIdentifier stringByAppendingString:langAppendString];
cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellViewIdentifier];
[cell setBackgroundColor:[UIColor clearColor]];
GCPlaceholderTextView * textArea= (GCPlaceholderTextView *)[cell viewWithTag:problemTypeTextViewTag];;
if (textArea != nil) {
textArea= (GCPlaceholderTextView *)[cell viewWithTag:problemTypeTextViewTag];
}else
{
textArea= (GCPlaceholderTextView *)[cell viewWithTag:kTagDescriptionTextArea];
[textArea setTag:problemTypeTextViewTag];
}
textArea.placeholder =getLocalizedString(@"Description");
textArea.delegate = self;
textArea.text = @"zaidi";
}
}
return cell;}
여기를 참고하십시오 http://stackoverflow.com/questions/26617151/how-come-my-uitableview-is-repeating-rows-after-5rows 및 기타 여러 가지. 테이블 셀은 재사용되므로 각 셀에 고유 한 데이터를 배열 (또는 행으로 인덱싱 할 수있는 다른 구조)에 보관해야합니다. 또한 동일한 수퍼 뷰를 사용하여 다른 텍스트 필드에 다른 태그를 사용해야합니다. – danh
다른 태그로, 당신은 내가 textview 및 각 태그를 고유하게 만드는 세 가지 프로토 타입 셀을 만들어야한다고 말하는 건가요? textview의 양이 증가한다면 그것은 쓸모가 없습니까? –
세 개의 텍스트보기가있는 셀이 하나있을 수 있지만 각 텍스트보기의 태그 속성을 할당하려는 경우 해당 정수 값은 고유해야합니다. – danh