Ios 在UICollectionViewCell中设置帧时,UIProgressView无法正常工作

Ios 在UICollectionViewCell中设置帧时,UIProgressView无法正常工作,ios,uicollectionview,uiprogressview,uicollectionviewcell,Ios,Uicollectionview,Uiprogressview,Uicollectionviewcell,我在UICollectionViewCell中创建了一个UIProgressView,我尝试设置UIProgressView的框架以更改UICollectionViewCell中的位置,但当这样做时,一些单元格不显示progressView。 当我删除setFrame时,它是OK的,但是UICollectionViewCell顶部的默认宽度 问题是什么?如何更改视图大小、原点?请帮忙 //Cell:UICollectionViewCell //Cell.m - (id)initWith

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

问题是什么?如何更改视图大小、原点?请帮忙

//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的代码。

[self.downloadBar setFrame:CGRectMake(0,10300,10)];我以前也这么做过,但不太好。现在,没事了,也许我的模拟器有问题。谢谢!你必须点击我答案左边答案勾号下方的100+