UIProgressView Progress Not Updated

I have a UIProgressView added to self.view as a subview. I have a UITableView with loaded rows. I need an image in each line, but I do not want the application to wait for them all, so I decided to start NSThread with loading the images. When I try to update the progress of a UIProgressView from within my stream, it does not update. Do I need to execute some delegates?

Initialization

    progressView = [[[UIProgressView alloc] initWithFrame:CGRectZero] autorelease];
    [progressView setFrame:CGRectOffset(CGRectMake(0, 0, 320, 8), 0, 1)];
    [self.view addSubview:progressView];

Then i start the thread

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [progressView setProgress:0.0];
    NSThread *myThread = [[NSThread alloc] initWithTarget:self
                                                 selector:@selector(imageLazyLoading)
                                                   object:nil];

    [myThread start];
    [pool release];
    [myThread release];

Then I try to update it

CGFloat pr;
for(int i=0; i < [self.itemsToDisplay count]; i++){
    if (!runThread) {
        return;
    }
    pr = (CGFloat)i/(CGFloat)[self.itemsToDisplay count]; 
    [self performSelectorOnMainThread:@selector(updateProgressBar:)
                           withObject: [NSNumber numberWithFloat:pr]
                        waitUntilDone: YES];
    progressView.progress += 0.5;.............

and nothing at all ...

+3
source share
2 answers

iOS 5.0. , 5.0, "" , setNeedsDisplay . 5.0 "" . , .

0

Source: https://habr.com/ru/post/1767184/


All Articles