使用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)hudViewTapGesture{
[HUD hide:YES];
}