当 UICollectionViewCell 中的 setFrame 时,UIProgressView 无法正常工作 [英] UIProgressView work not correctly when setFrame in UICollectionViewCell

查看:27
本文介绍了当 UICollectionViewCell 中的 setFrame 时,UIProgressView 无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I create a UIProgressView inside UICollectionViewCell, I try to setFrame for UIProgressView to change position in UICollectionViewCell but when do that, some cells not display progressView. When I delete setFrame, It's OK but default width at the top of UICollectionViewCell

有什么问题?如何更改 UIProgressView 的大小、原点?请帮忙!

What's the problem?How to change UIProgressView size, origin? Please help!

//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的frame

I have modified you code. Now, progress view is working properly. All cells are showing the progress view. Also, width & position of the cell can be modified, if you change the frame of self.downloadBin the below code

- (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 的代码.

I have modified the code of cell.m from the github url which you have provided.

这篇关于当 UICollectionViewCell 中的 setFrame 时,UIProgressView 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆