// // AgreementViewController.m // Ifish // // Created by imac on 15/10/26. // Copyright © 2015年 imac. All rights reserved. // #import "AgreementViewController.h" #import "MBProgressHUD.h" @interface AgreementViewController () @property(nonatomic,strong)UIWebView*myWebView; @property(nonatomic,strong)MBProgressHUD *HUD; @end @implementation AgreementViewController - (void)viewDidLoad { [super viewDidLoad]; [self initWebView]; [self addTitleViewWithTitle:@"爱鱼奇用户注册协议"]; } -(void)creatHUd{ _HUD=[MBProgressHUD showHUDAddedTo:self.myWebView animated:YES]; _HUD.delegate=self; _HUD.color=[UIColor lightGrayColor]; _HUD.labelText=@"loding..."; _HUD.detailsLabelText=@"加载中"; _HUD.backgroundColor=[UIColor colorWithRed:36.0/256.0 green:72.0/256.0 blue:107.0/256.0 alpha:1];; _HUD.dimBackground=YES; } -(void)initWebView{ self.myWebView=[[UIWebView alloc]initWithFrame:self.view.bounds]; // NSURLRequest*requst=[NSURLRequest requestWithURL:[NSURL URLWithString:kIfishHtml]]; NSString*filepath=[[NSBundle mainBundle]pathForResource:@"service" ofType:@"html"]; NSString*html=[NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:nil]; [self.myWebView loadHTMLString:html baseURL:[NSURL URLWithString:filepath]]; [self.view addSubview:self.myWebView]; } -(void)webViewDidStartLoad:(UIWebView *)webView{ [self creatHUd]; } -(void)webViewDidFinishLoad:(UIWebView *)webView{ [_HUD hide:YES afterDelay:2.0]; } -(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ [_HUD hide:YES afterDelay:2.0]; [self showLableAction:@"加载失败"]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)showLableAction:(NSString *)str{ UILabel *laberAction =[[UILabel alloc]init]; laberAction.frame =CGRectMake(kScreenSize.width/2 - 75, kScreenSize.height/2 - 75, 150, 50); laberAction.clipsToBounds =YES; laberAction.layer.cornerRadius =3; laberAction.alpha =1.0; laberAction.text =str; laberAction.textAlignment =NSTextAlignmentCenter; laberAction.backgroundColor =[UIColor grayColor]; [UIView animateWithDuration:2.0 animations:^{ laberAction.alpha =0; }completion:^(BOOL finished) { [laberAction removeFromSuperview]; }]; [self.view addSubview:laberAction]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end