Когда я прокручивать TableView дает этот тип перекрытия Когда Scroll UITableView это перекрываться имя IOS
Я пишу код, приведенный ниже в методе CellForRow AtIndexPath, я создаю TableView ... программно
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
NSDictionary *info = [ASSETHELPER getGroupInfo:_groupArray[indexPath.row]];
UIImageView *view;
if (indexPath.row % 2) {
view=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"dark_bg"]];
}else{
view=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"light_bg"]];
}
cell.backgroundView=view;
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
imgView.backgroundColor=[UIColor clearColor];
[imgView.layer setCornerRadius:25];
[imgView.layer setMasksToBounds:YES];
[imgView.layer setBorderColor:[UIColor whiteColor].CGColor];
[imgView setImage:[info objectForKey:@"thumbnail"]];
[cell.contentView addSubview:imgView];
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(80, 20, 200, 30)];
[label setText:[info objectForKey:@"name"]];
[cell.contentView addSubview:label];
return cell;
}
Мы не волшебники и не экстрасенсы. Добавьте код и более подробную информацию. – n00bProgrammer
Вы неправильно обработали повторное использование ячеек. разместите здесь свой код cellPathForRowAtIndexPath. – Yogendra
Гораздо лучше. Извините, если раньше я казался грубым. Здесь проблема '[cell.contentView addSubview: label];'. Каждый раз, когда вызывается 'cellForRowAtIndexPath:', вы каждый раз добавляете новую метку. Поскольку ячейки повторно используются, ярлык, добавленный ранее, никогда не удаляется. – n00bProgrammer