views:

18

answers:

1

Hi there

My UIProgressView is going to the top right hand corner of the main view - even though I set it as a subview of a UIView (which in turn is a subview of the main view). And even if I setFrame:.

Any ideas?

if(downloadBar == nil){
  downloadBar = [[UIProgressView alloc] initWithFrame:CGRectMake(10, 10, 200, 10)];
}
[downloadBar setProgressViewStyle:UIProgressViewStyleDefault];
[downloadBar setProgress:([download downloadStatus]/100.0f)];
[downloadView addSubview:downloadBar];



// download view initialisation
// this is initalised BEFORE the download bar
    downloadView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 300, 300)];
        [downloadView setBackgroundColor:[UIColor lightGrayColor]];
        [self.view addSubview:downloadView];
        [downloadView retain];

Thanks

A: 

I think it depends on your downloadView. Because the origin coordinate (0, 0) of downloadBar will be at the same position of the origin coordinate (0, 0) of the downloadView. So, if you downloadView is located in top right, the downloadBar will be the same

vodkhang
fair enough, but the progress view has an origin (10,10) so even if the downloadView is at (0,0) (which it isn't) the progress view should still be inset by (10,10) surely?
Thomas Clayson
no, the origin of the progress view is relative to the download view. If your downloadView.frame.origin is (x, y) and your progressView.frame.origin is (10, 10), then the exact coordination in the screen will be (x + 10, y + 10)
vodkhang
ah i see what you mean... :( it wasn't that - but thanks to you i've found a silly mistake - I'm init-ing the progress view in two places with the same code, but with a different origin, and adding to a different view. :/ lol. :) thanks for trying to help :) have some rep.
Thomas Clayson