MBProgressHUD长时间加载没法取消的解决方法

使用MBProgressHUD时,加载网路数据,或者等待webview加载完毕,长时间的等待致使体验不佳,这时候但愿点击屏幕取消加载动画效果;web

 

//  MBProgressHUD.h

@protocol MBProgressHUDDelegate <NSObject>

@optional

/** 
 * Called after the HUD was fully hidden from the screen. 
 */
- (void)hudWasHidden:(MBProgressHUD *)hud;

-(void)hudViewTapGesture;

@end



//  MBProgressHUD.m

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    if ([self.delegate respondsToSelector:@selector(hudViewTapGesture)]) {
        [self.delegate performSelector:@selector(hudViewTapGesture)];
    }
}


//viewcontroller.m

-(void)hudViewTapGesture{    [HUD hide:YES]; }
相关文章
相关标签/搜索