Search code examples
iosnetwork-programminghideshowindicator

Network Indicator IOS


I would like to ask that is there a way to show network indicator automatically when there is network activity going on and hide the network indicator when there is no network activity


Solution

  • You have to control it by using your start and completion of your network calls.

    Lets say:

        - (void)viewDidAppear:(BOOL)animated{
          [super viewDidAppear:animated];
          [self showNetworkActivitySpinner];
          [self fetchDataFromServer];
        }
    
        - (void)fetchDataFromServer{
          [SomeApiCallClass callWebServiceWithPostData:(NSDictionary *)someDataToPost andCompletionHandler:(^void) {
            [self hideNetworkActivitySpinner];
          }];
        }