iOS: SVProgressHUD doesnt dismiss when user moves from one screen to another in IOS Xcode

旧城冷巷雨未停 提交于 2019-12-31 04:01:06

问题


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


回答1:


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];}



回答2:


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.



来源:https://stackoverflow.com/questions/30642980/ios-svprogresshud-doesnt-dismiss-when-user-moves-from-one-screen-to-another-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!