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

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

//  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)hudViewWasTapped {
    [HUD hide:YES];
}

 

文章来自:http://www.cnblogs.com/mangoes/p/4702644.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3