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 nee开发者_如何学JAVAd to wait (ie. loading dialog) until the method completes and then show the screen with data.
How do I do this?
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.
-(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];
}
精彩评论