EDIT: I have added a screenshot of the problemизготовленный под заказ коллекцию посмотреть ячейку
Я использовал пользовательскую коллекцию View Cell. Проблема в том, что когда я просматриваю список по горизонтали, я получаю 2 изображения в моем представлении изображения в некоторых ячейках. Пожалуйста, помогите мне понять, почему это происходит и как я могу его исправить?
Это вид коллекции code-
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// static NSString * const reuseIdentifier = @"cell3";
MostPopularViewCell *cell3 = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
cell3.clipsToBounds=YES;
cell3.mostproductprice.text=[[mostPopularArr objectAtIndex:indexPath.row] objectForKey:@"name"];
cell3.mostproductnm.text=[[mostPopularArr objectAtIndex:indexPath.row] objectForKey:@"pirce"];
NSDictionary *Scrapdict=[mostPopularArr objectAtIndex:indexPath.row];
NSString *img_str=[Scrapdict objectForKey:@"small_image"];
NSURL *url=[NSURL URLWithString:img_str];
AsyncImageView *imageView = [[AsyncImageView alloc] initWithFrame:cell3.mostProductimg.bounds];
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView];
//set image URL. AsyncImageView class will then dynamically load the image
((AsyncImageView *)imageView).imageURL =url;
// imageView.clipsToBounds=YES;
imageView.userInteractionEnabled=YES;
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.userInteractionEnabled=YES;
cell3.backgroundColor=[UIColor clearColor];
cell3.mostProductimg.image=nil;
//imageView.layer.cornerRadius = 10;
imageView.backgroundColor=[UIColor clearColor];
//cell3.mostProductimg.clipsToBounds=YES;
[cell3.mostProductimg addSubview:imageView];
cell3.mostProductimg.userInteractionEnabled=YES;
[AsyncImageLoader defaultCache];
[[AsyncImageLoader sharedLoader]loadImageWithURL:url target:nil success:nil failure:nil];
// cell3.mostProductimg.clipsToBounds=YES;
cell3.mostPopularviewbtn.tag = indexPath.row;
[cell3.mostPopularviewbtn addTarget:self action:@selector(btnClick3:) forControlEvents:UIControlEventTouchUpInside];
// Configure the cell
return cell3;
}
вид сбора клеток code-
- (void)awakeFromNib {
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code
NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"MostPopularViewCell" owner:self options:nil];
if ([arrayOfViews count] < 1) {
return nil;
}
if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]]) {
return nil;
}
self = [arrayOfViews objectAtIndex:0];
}
return self;
}
Можете ли вы предоставить скриншот того, что вы хотите и как оно выглядит сейчас? – Adeel
Как подключить скриншот? –
Редактировать свой вопрос и в текстовом режиме нажать «cntrl + g». Он откроет окно для выбора изображения из вашей системы. – Adeel