I am using iPhone to get data from my web service.
Because I wan’t to display loading view while getting data I invoke web service synchronous.
I have button which navigate to table view (that get data from ws):
Loading *loading = [[Loading alloc]init];
[[[UIApplication sharedApplication] keyWindow] addSubview:loading.view];
TableViewController *tableViewController = [[TableViewController alloc] init];
[self.navigationController pushViewController:tableViewController animated:YES];
[loading.view removeFromSuperview];
And I call web service in viewDidLoad of my view.
webData = [NSURLConnection sendSynchronousRequest:req
returningResponse:&response
error:&error];
NSString *xml= [[NSString alloc] initWithBytes:[webData mutableBytes]
length:[webData length]
encoding:NSUTF8StringEncoding];
// Parse XML etc.
I have tried to add loading view before I call web service (in viewDidLoad) but still doesn’t work.
Any idea how to display loading view?
You should call the web service asynchronously. By doing it synchronously, you are blocking the main (UI) thread & it can’t finish loading your view or make it appear (or animate things on the loading view), etc.