以编程方式添加的imageView在集合视图中显示为垃圾,同时将其从横向模式更改为纵向模式

时间:2016-06-14 06:20:04

标签: ios uicollectionview

我已经在集合视图单元格中以编程方式添加了imageview和标签,它首次完美地以纵向模式显示,当我将方向从横向更改为纵向时它没有完美显示,在同一图像上显示为重叠。我已经在rowat indexpath的collectionview单元格中编写了以下代码。  »»»»»»»帮我解决这个问题

UILabel *titleLable;
UIImageView *ImageView;
int sectionValue=(int)collectionView.tag;
GDColVwCell*cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"CVCell" forIndexPath:indexPath];


ImageView=[[UIImageView alloc]initWithFrame:CGRectMake(20, 0,self.view.frame.size.width-40, heightForImageView)];
titleLable=[[UILabel alloc]initWithFrame:CGRectMake(20, ImageView.frame.size.height-50, self.view.frame.size.width-40, 50)];


titleLable.text= [[[[titleNamesArr objectAtIndex:sectionValue] objectForKey:@"videos"]  objectAtIndex:indexPath.row] objectForKey:@"title"];


titleLable.textAlignment=NSTextAlignmentCenter;


  titleLable.numberOfLines=2;

    titleLable.font = [UIFont fontWithName:@"Arial-BoldMT" size:17];
  titleLable.backgroundColor=[[UIColor blackColor] colorWithAlphaComponent:0.5];

titleLable.textColor=[UIColor whiteColor];




NSString *imgString=[[[[titleNamesArr objectAtIndex:sectionValue] objectForKey:@"videos"]  objectAtIndex:indexPath.row] objectForKey:@"thumb"];
NSURL * url=[NSURL URLWithString:imgString];
NSLog(@"USE PROFILE IMAGE URL IN ViewDidLoad=>%@",url);


[ImageView sd_setImageWithURL:url placeholderImage:[ UIImage imageNamed:@"logo"]];


cell.backgroundColor=[UIColor whiteColor];
[cell.contentView addSubview:ImageView];
[cell.contentView addSubview:titleLable];

return cell;

0 个答案:

没有答案