UIProgressView在UICollectionViewCell中的setFrame时不能正确工作

我在UICollectionViewCell中创build一个UIProgressView,我尝试为UIProgressView设置框架来更改UICollectionViewCell中的位置,但是当这样做时,一些单元格不显示progressView。 当我删除setFrame时,没问题,但在UICollectionViewCell顶部的默认宽度

有什么问题?如何更改UIProgressView的大小,来源? 请帮忙!

//Cell:UICollectionViewCell //Cell.m - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { //ProgressView self.progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar]; [self.progressView setFrame:progressViewFrame];//Some cells not display progressView [self.progressView addSubview:self.downloadBar]; } return self; } 

我修改了你的代码。 现在,进度视图正常工作。 所有单元格都显示进度视图。 另外,如果在下面的代码中更改self.downloadB的框架,则可以修改单元格的宽度和位置

 - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code [self.contentView setBackgroundColor:[UIColor underPageBackgroundColor]]; //cellImage self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 0, 57, 57)]; [self.imageView setBackgroundColor:[UIColor clearColor]]; [self.contentView addSubview:self.imageView]; //ProgressView self.downloadBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar]; [self.downloadBar setFrame:CGRectMake(0, 10, 300, 10)]; [self.contentView addSubview:self.downloadBar]; [self.downloadBar setHidden:YES]; self.receivedData = [[NSMutableData alloc] init]; } return self; } 

我已经从你提供的github url修改了cell.m的代码。