MBProgressHUD的原理
http://iphonedevelopment.blogspot.com/2010/02/implementing-wait.html
Download
https://github.com/jdg/MBProgressHUD
Installation
下载解压之后,把下列两个file copy to your project即可。
MBProgressHUD.h
MBProgressHUD.m
How to use?
完整例子参看下载zip file里的Demo目录下的example project。
最简单的使用代码:
#import"MBProgressHUD.h"
...
// The hud will dispable all input on the view (use the higest view possible in the view hierarchy)
// 参数initWithView的值应该是the highest view possible,
//在MBProgressHUD zip file提供的example里该参数值为self.navigationController.view,
//但如果你创建的是single view project的话,就会出错,因为self.navigationController is nil
MBProgressHUD *hud = [[MBProgressHUDalloc]initWithView:self.view];
[self.viewaddSubview:hud];
// Regiser for HUD callbacks so we can remove it from the window at the right time
// self必须在.h file里声明实现 "<MBProgressHUDDelegate>" 接口,同时在.m file里添加"hudWasHidden" method
//该方法是一个回调方法,当你执行"[hud hide:YES];"时,就会回调它
hud.delegate =self;
//show pregress hud
[hud show:YES];
- (void)hudWasHidden:(MBProgressHUD *)hud {
// Remove HUD from screen when the HUD was hidded
[hudremoveFromSuperview];
hud =nil;
}
[hudshow:YES];
[hud show:YES];
[hud removeFromSuperview];
hud = nil;