iOS:当用户在IOS Xcode中从一个屏幕移动到另一个屏幕时,SVProgressHUD不会被忽略 [英] iOS: SVProgressHUD doesnt dismiss when user moves from one screen to another in IOS Xcode
问题描述
我已经使用SVProgressHUD进行了进展。我发现当用户从一个屏幕移动到另一个屏幕时,SVProgressHUD不会被忽略。在每个班级的 - (void)viewWillDisappear:(BOOL)动画
中调用 [SVProgressHUD dismiss];
是很繁琐的我想找到更好的解决方案。目前我已经实现了以下代码但我想找到一些更好的方法
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];
}
我知道要解雇HUD,我们需要调用以下方法之一:
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;
但我不想打电话给 [SVProgressHUD解雇];
in - (void)viewWillDisappear:(BOOL)动画
每个类,因为在每个类的整个项目中编写相同的代码不是编码的好方法
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
推荐答案
你可以创建一个超类,其中每个使用SVProgressHUD的类都继承该类,在超类中你可以这样做:
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];}
这篇关于iOS:当用户在IOS Xcode中从一个屏幕移动到另一个屏幕时,SVProgressHUD不会被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!