views:

19

answers:

1
            [progressind startAnimating];

        [self performSelectorOnMainThread:@selector(methodgoeshere:) withObject:[NSDictionary dictionaryWithObjectsAndKeys: aURL, @"aURL", aURL2, @"aURL2", nil]
                            waitUntilDone:YES ];
        [progressind stopAnimating];

        [navigationController pushViewController:vFullscreen animated:YES];

In the methodgoeshere, i have a UIImageview which i fill with the image once its downloaded but the problem is, the activityprogress is not working as i thought, it doesnt spin.

+1  A: 

You need to do your image loading in a new background thread. performSelectorOnMainThread calls the method on the main thread, not a background thread so that's why it's blocking.

To call your image loading method in a background thread:

[progressind startAnimating];
[NSThread detachNewThreadSelector:@selector(methodgoeshere:) toTarget:self withObject:[NSDictionary dictionaryWithObjectsAndKeys: aURL, @"aURL", aURL2, @"aURL2", nil]];

Then in methodgoeshere you load your image. Once the image is done loading then you call a method on the main thread to let it know you're done and to stop the activity progress indicator.

- (void) methodgoeshere:(...)... {
    // <Load your image here>

    // Then tell the main thread that you're done
    [self performSelectorOnMainThread:@selector(imageDoneLoading) withObject:nil waitUntilDone:YES ];        
}

- (void)imageDoneLoading {
    [progressind stopAnimating];
    // Do other stuff now that the image is loaded...
}
Nebs
Thanks, Exactly what i wanted ;)