How to show the loading indicator in the top status bar

后端 未结 8 2010
借酒劲吻你
借酒劲吻你 2020-12-04 06:37

I have noticed that some apps like Safari and Mail show a loading indicator in the status bar (the bar at the very top of the phone) when they are accessing the network. Is

相关标签:
8条回答
  • 2020-12-04 07:19

    It might also be helpful to make sure you are running it on the main thread as it is UI related.

    dispatch_async(dispatch_get_main_queue(), ^{
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    });
    
    0 讨论(0)
  • 2020-12-04 07:20

    You need to take care of hiding the activity indicator also once your network call is done.

    If you use AFNetworking, then you don't need to do much.

    Do following changes in AppDelegate Class:

    1. Import AFNetworking/AFNetworkActivityIndicatorManager.h

    2. Put this in didFinishLaunchingWithOptions:

    [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]

    0 讨论(0)
提交回复
热议问题