1

I have used SVProgressHUD for progresshud. I found that SVProgressHUD doesnt dismiss when user moves from one screen to another. Its tedious to call [SVProgressHUD dismiss]; in -(void)viewWillDisappear:(BOOL)animated of every class so i want to find the better solutions. Currently i have implemented below code But I want to find some better methods

-(void)viewWillDisappear:(BOOL)animated{
  [SVProgressHUD dismiss];
}

SVProgressHUD in Git.

I know To dismiss the HUD we need to call one of the following method:

+ (void)dismiss;
+ (void)dismissWithSuccess:(NSString*)successString;
+ (void)dismissWithSuccess:(NSString*)successString afterDelay:(NSTimeInterval)seconds;
+ (void)dismissWithError:(NSString*)errorString;
+ (void)dismissWithError:(NSString*)errorString afterDelay:(NSTimeInterval)seconds;

But I dont want to call [SVProgressHUD dismiss]; in -(void)viewWillDisappear:(BOOL)animated of every class since writing same code in overall projects in each class is not good way of coding

Juan Catalan
  • 2,299
  • 1
  • 17
  • 23
Nischal Hada
  • 3,230
  • 3
  • 27
  • 57
  • Are you using storyboards? You could create a custom segue that removes the ProgressHUD if its visible, then set the segue type to that for each xib with a ProgressHUD. – Toby Jun 04 '15 at 12:42

2 Answers2

4

You can create a super class where every class that uses the SVProgressHUD inherit that class and in the super class you can do like this :

-(void)viewWillDisappear:(BOOL)animated{
if([SVProgressHUD isVisible]) 
 [SVProgressHUD dismiss];}
0

Objective C

Write in AppDelegate.m file.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //add this line
    [SVProgressHUD setDefaultMaskType: SVProgressHUDMaskTypeBlack];
}

This code worked to everywhere in project.

Deepak Tagadiya
  • 2,187
  • 15
  • 28