简体   繁体   中英

how to set and dismiss SVProgressHUD when move to another ViewController

I want to show progress bar when press a button to move another ViewController (This ViewController is load with huge amount of data from the WebService) and after load all data progress bar will be dismiss.

I mean first press a button then immediately move to another ViewController with progress bar and progress bar dismiss after load all data.

here I add the code for move to another ViewController :

UIStoryboard *sb=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
Guide *guideVC = [sb instantiateViewControllerWithIdentifier:@"Guide"];
[self.navigationController pushViewController:guideVC animated:YES];

And WebService simply fetch in viewDidLoad method on new ViewController .

How can I do this. Any one give the solution.

Here i have just show you how to dissmiss SVProgress Here i have used my own APIManager(Using Alamofire) Custom class for Api calling

override func viewDidLoad() {
        super.viewDidLoad()
        self.fetchList()
    }
    func fetchList() {
        SVProgressHUD.show()
        APIManager.callAPIRequest(Method: .post, url: urlStr, parameters: parameters, headers: headers, completion:
            { (result, headerMessage) in
                let dicJSONResponse = result.dictionaryValue
                //SuccessBlock
                SVProgressHUD.dismiss()
        }) { (httpresponse, errorMessage) in
            //Failure blog
            SVProgressHUD.dismiss()
        }
    }

Please do the following:

  1. I think you are using a basewebservice(parent class) for all your webservice task.
  2. Start the progress bar before the webservice call(call GET, POST, PUT and PATCH).
  3. Stop the progress bar after getting success or failure callbacks.
  4. If you have to process very large data, please run it in the background thread for the smooth working of UI thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM