1

In my project there is left & right slide menu,so if i tap on left menu's cell one UIViewController is call in this UIViewControllers viewDidLoad method.

i am calling SOAP based web service. So my question is when i tap on UITableViewCell.view is not getting fully loaded in to screen it is stuck at there. and view is fully load and i can see on full display when data comes from web service.

so i have to wait for data come than i can see whole UIView. So how to load UIViewController at first tap? and after UIView is appear i will put activity indicator that's why user can see at least data is loading in UIView.

Thanks in advance please any one can help me to get out of this problem.

Edit:I have tried to call web service method to viewWillAppear

Ashok Londhe
  • 1,491
  • 11
  • 29
kins parikh
  • 15
  • 1
  • 7
  • 1
    use background threading – vijeesh May 13 '15 at 12:41
  • Don't call web service within `viewDidLoad`, put it in `viewDidAppear`, and use `dispatch_async(dispatch_get_global_queue()` for web service call – Viral Savaj May 13 '15 at 12:41
  • can u post your code ,so we can get more clear understanding – Mukesh May 13 '15 at 12:41
  • i already call within `dispatch_async(dispatch_get_main_queue(), ^` for async call. – kins parikh May 13 '15 at 12:43
  • @ViralSavaj Ahem, web services calls on main thread are **really** not a good idea. – Blackus May 13 '15 at 12:44
  • yup i had already tried out calling web service from viewDidAppear. – kins parikh May 13 '15 at 12:46
  • code for now: `-(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [activityIndicator startAnimating]; [self callWebService]; }` and in web service method ` response = [binding Index_global:request]; dispatch_async(dispatch_get_main_queue(), ^{ NSString *responseString = [self getDataFromWebServiceResponse:response]; if (responseString!=nil) { [self processData:responseString]; } }` – kins parikh May 13 '15 at 12:48

2 Answers2

1
- (void)performBackgroundTask
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //Do background work   (call your Web service method here)
        dispatch_async(dispatch_get_main_queue(), ^{
            //Update UI
        });
    });
}

Call Webservice in Background work and use main queue for loading Tableview

vijeesh
  • 1,317
  • 1
  • 17
  • 32
0
 - (void)viewDidLoad {
[super viewDidLoad]; 

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{

    //Call ur web service in view did load or appear and add data in datsource of tableview

    dispatch_async(dispatch_get_main_queue(), ^{
        //table view reload data
    });

});

}
Mukesh
  • 3,680
  • 1
  • 15
  • 32
  • the above answer is accepted,if u see properly .dont just downvote any answer just for fun.its just we both answered at sametime – Mukesh May 14 '15 at 08:06