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]; }
相關文章
相關標籤/搜索