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

时间:2013-01-27 06:06:39

标签: ios uicollectionview uiprogressview uicollectionviewcell

我在UICollectionViewCell中创建一个UIProgressView,我尝试使用UFrogressView的setFrame来改变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;
    }

1 个答案:

答案 0 :(得分:0)

我修改了你的代码。现在,进度视图正常工作。所有单元格都显示进度视图。另外,宽度&如果您在以下代码中更改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网址修改了cell.m的代码。