Nadhas
Nadhas

Reputation: 5807

Load screen after finishing web service calls

My first screen that contains a uitableview, I used to call webservice method in viewdidload:

- (void)viewDidLoad {
[super viewDidLoad];

self.navigationItem.title =@"Brand List";

getBrands *obj = [[getBrands alloc]init];
[obj getBrandsList];

getBrandsList, but before the webservice finished, it loads the screen, so the screen contains an empty list.

So I need to wait (ie. loading dialog) until the method completes and then show the screen with data.

How do I do this?

Upvotes: 0

Views: 325

Answers (2)

Nadhas
Nadhas

Reputation: 5807

-(IBAction) buttonClick: (id) sender{

    //show loading dialog here(activity indicator)
    [self performSelectorInBackground:@selector(callWebService) withObject:nil];    

  }

-(void) callWebService
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];

    //resend request and parse response.
   // create new view controller object and push screen
    // hide loading indicator

    [pool release];
}

Upvotes: 0

Alex Terente
Alex Terente

Reputation: 12036

Create an new View with an UIActivityIndicatorView and an UILabel. Then add it on top of your window with some CATransition. When you finish download remove this screen.

Upvotes: 2

Related Questions