进入一个页面加载数据时显示loading
使用的是 http://code4app.com/ios/MBProgressHUD/4f67fa776803fa3449000000 MBProgressHUD
.m
@interface DetailViewController : UIViewController<UIWebViewDelegate,MBProgressHUDDelegate> {
MBProgressHUD *HUD;
IBOutlet UIWebView *webViews;
}
@property (copy, nonatomic) NSDictionary *data;
使用的是 http://code4app.com/ios/MBProgressHUD/4f67fa776803fa3449000000 MBProgressHUD
.m
@interface DetailViewController : UIViewController<UIWebViewDelegate,MBProgressHUDDelegate> {
MBProgressHUD *HUD;
IBOutlet UIWebView *webViews;
}
@property (copy, nonatomic) NSDictionary *data;
.h
-(void)showHUD{
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
[HUD show:YES];
// [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
webViews.delegate=self;
NSString *string = [NSString stringWithFormat:@"%@docdetail/detail?uid=%@", BaseURLString,self.data];
NSURL *url = [NSURL URLWithString:string];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webViews loadRequest:request];
}
-(void) webViewDidStartLoad:(UIWebView *)webView{
[self showHUD];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
[HUD hide:YES];
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
NSLog(@"%@",error);
}
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
[HUD show:YES];
// [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
webViews.delegate=self;
NSString *string = [NSString stringWithFormat:@"%@docdetail/detail?uid=%@", BaseURLString,self.data];
NSURL *url = [NSURL URLWithString:string];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webViews loadRequest:request];
}
-(void) webViewDidStartLoad:(UIWebView *)webView{
[self showHUD];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
[HUD hide:YES];
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
NSLog(@"%@",error);
}