1。 网上下载 MBProgessHUD 类,导入到工程。
https://github.com/jdg/MBProgressHUD2。#import "MBProgressHUD.h"
类实现 MBProgressHUDDelegate 代理。
3。 在类里面定义:
MBProgressHUD* progress_;
4。 显示;
- progress_ = [[MBProgressHUD alloc] initWithView:self.tableView];
- [self.view addSubview:progress_];
- [self.view bringSubviewToFront:progress_];
- progress_.delegate = self;
- progress_.labelText = @"加载中...";
- [progress_ show:YES];
隐藏:
- if (progress_)
- {
- [progress_ removeFromSuperview];
- [progress_ release];
- progress_ = nil;
- }
5。实现协议:
- - (void)hudWasHidden:(MBProgressHUD *)hud
- {
- NSLog(@"Hud: %@", hud);
- // Remove HUD from screen when the HUD was hidded
- [progress_ removeFromSuperview];
- [progress_ release];
- progress_ = nil;
- }