0

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

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;
    }
LE SANG
  • 10,955
  • 7
  • 59
  • 78

1 Answers1

0

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;
}

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

Bharath
  • 3,001
  • 6
  • 32
  • 65
  • [self.downloadBar setFrame:CGRectMake(0, 10, 300, 10)]; I do the same before but It not OK. Now, It's OK, maybe problem inside my simulator.Thanks! – LE SANG Jan 29 '13 at 08:55
  • You have to click on 100+ below the answer tick, to the left side of my answer – Bharath Jan 29 '13 at 09:03