Question

First of all sorry about my english, it´s not my native language.

I am developing an iOS app that collects data from a JSON and displays them in a table. Everything works correctly . My problem is that JSON has many data and the app takes several seconds until it show the data. So , I need to put a charge indicator to alert the user to wait until the application has loaded the data. To use the charging indicator I downloaded Seller SVProgressHUD :

https://github.com/samvermette/SVProgressHUD

I've integrated SVProgressHUD into my application but I can not make it work as I want.

In my application I have a class AppDelegate and a class MasterViewController (where I load JSON data , populate the tableView and show the tableView)

What I want is when the application starts his executions it shows the SVProgressHUD with the text "Loading" and when the tableView with all the data appears, the SVProgressHUD dissapears.

For this, I added this line of code in my class AppDelegate in the method didFinishLaunchingWithOptions:

[SVProgressHUD showWithStatus:@"Cargando" maskType:SVProgressHUDMaskTypeBlack];

And in my class MasterViewController, in the viewDidLoad method I have added this line of code:

[SVProgressHUD dismiss];

After adding these lines of code, my application runs as ever and doesn't show charging indicator.

I think it may be because in the didFinishLaunching still no loaded view where you can show charging indicator but I don´t know what is the code that I have to add to make it works.

A greeting and thanks for the help .

Was it helpful?

Solution

Place this code before you send your json request for fetching data

[SVProgressHUD showWithStatus:@"Updating" maskType:SVProgressHUDMaskTypeBlack];

I have used afnetworking in my application. So when it returns success, i dismiss the SVProgressHUD.

[client postPath:@"xyz.com/abcd" parameters:params1 success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [SVProgressHUD dismiss];
   }failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [SVProgressHUD dismiss];
 }];

Hope it is helpful to you.

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top