0
내 UITableView
셀은 다른 셀의 내용 (이미지)을 가져옵니다. 왜 그런 일이 일어날 지 모르지만 내 실수는 어리 석다. 아래 이미지에서 보이는 모양을 볼 수 있습니다. 상단의 셀은 하단의 셀에서 이미지를 가져옵니다 (facebook 및 twitter 아이콘). UITableView 셀은 다른 셀의 내용을 가져옵니다.
- (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];
}
NSDictionary *dictionary = [mainArray objectAtIndex:indexPath.section];
NSArray *array1 = [dictionary objectForKey:@"stuff"];
NSString *cellValue = [array1 objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue; // загаловок клетки
cell.textLabel.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:16];
cell.textLabel.textColor = [UIColor colorWithRed:145/256.0 green:0/256.0 blue:0/256.0 alpha:1.0];
cell.backgroundColor = [UIColor whiteColor];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.textLabel.textAlignment = UITextAlignmentLeft;
if (indexPath.section == 0 && indexPath.row == 1)
{
if([[NSUserDefaults standardUserDefaults]boolForKey:@"password"] == YES)
{
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
}
switch(indexPath.section)
{
case 2:
{
cell.textLabel.textAlignment = UITextAlignmentCenter;
}
break;
case 3:
{
if (indexPath.row == 0)
cell.imageView.image = [UIImage imageNamed:@"facebook"];
else if (indexPath.row == 1)
cell.imageView.image = [UIImage imageNamed:@"twitter"];
else if (indexPath.row == 2)
cell.imageView.image = [UIImage imageNamed:@"youtube"];
else
cell.imageView.image = [UIImage imageNamed:@"vk"];
}
break;
default:
break;
}
return cell;
}
내가 그것을 어떻게 해결할 수 있습니다 : 여기
는 cellForRowAtIndexPath 내 코드?
나는이 코드 부분에서 오류를 볼 수 없었지만 추적 방법을 제안 할 것입니다. '1'과'0' (이미지가없는 경우)에'case'를 추가하고'cell.imageView.image'를'nil'으로 설정하십시오. 이 경우 우리는 셀이이 코드 또는 다른 곳에서 이미지를 가져 오는 지 알 수 있습니다. – antf