Use of MBProgressHUD Globally + make it singleton

后端 未结 9 1212
时光说笑
时光说笑 2020-12-23 02:06

In my Project, each of the user interaction events make a network call (Which is TCP, not HTTP). I need Activity Indicator to be global to show from a rando

9条回答
  •  悲哀的现实
    2020-12-23 02:25

    Note: Considering the views this Question is getting I decided to post the the way I did choose as a solution. This is NOT an answer to my question. (Hence, the accepted answer remains accepted)

    At that time I ended up using SVProgressHUD as it was very simple to integrate and use.

    All you need to do is just drag the SVProgressHUD/SVProgressHUD folder into your project. (You may choose to go for cocoapods OR carthage, as well)


    In Objective-C:

    [SVProgressHUD show]; // Show
    [SVProgressHUD dismiss]; // Dismiss
    

    In Swift:

    SVProgressHUD.show() // Show
    SVProgressHUD.dismiss() // Dismiss
    

    Additionally, Show and hide HUD needs to be executed on main thread. (Specifically you would need this to hide the HUD in some closure in background)

    e.g.:

    dispatch_async(dispatch_get_main_queue(), ^{
        [SVProgressHUD dismiss]; // OR SHOW, whatever the need is.
    });
    

    There are additional methods for displaying custom messages with HUD, showing success/failure for short duration and auto dismiss.

    MBProgressHUD still remains a good choice for developers. It's just that I found SVProgressHUD to suit my needs.

提交回复
热议问题