2016-02-20 web view

  

#import "MedDetitleViewController.h"

@interface MedDetitleViewController ()<UIScrollViewDelegate,UIWebViewDelegate>{

    UIImageView *imagershujuMed;

    UILabel *tiwuxianLabmed;

    UIScrollView *scrviewll;

    

    UIWebView  *webvieww1111;

}

@end

@implementation MedDetitleViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

//    NSString *Strsubit =self.MedDetalDic[@"name"];

//    NSString *Sttit ;

//    if (Strsubit.length>7) {

//        Sttit =[NSString stringWithFormat:@"%@...",[Strsubit substringToIndex:7]];

//    }

//    else{

//        

//        Sttit = Strsubit;

//    }

//    

//    

//    self.title=Sttit;

//    

     self.title=@"药品说明";

    [self navBarUi];

    

    UIWebView *viewWeb = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];

    webvieww1111=viewWeb;

    viewWeb.backgroundColor = [UIColor whiteColor];

    viewWeb.delegate =self;

    

    [self.view addSubview:viewWeb];

    

    

    

    

    [self showTishi11];

    

    NSString *path=[NSString stringWithFormat:@"%@",_MedDetalDic[@"htmlPath"]];

    NSString *url = [NSString stringWithFormat:@"%@%@",ImageUrl,path];

//

//    

    [viewWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];

//    NSLog(@" =url=%@",url);

    

    if ([_MedDetalDic count]<=0||_MedDetalDic==nil) {

        imagershujuMed.hidden = NO;

        tiwuxianLabmed.hidden = NO;

    }else{

        imagershujuMed.hidden = YES;

        tiwuxianLabmed.hidden = YES;

    }

}

-(void)navBarUi{

    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"gdback3"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(backClickMedicine)];

    self.navigationItem.leftBarButtonItem=backItem;

    //自定义后退按钮后,手势返回上一级控制器的功能恢复

    self.navigationController.interactivePopGestureRecognizer.delegate = nil;

}

//提示

-(void)showTishi11{

    

    //1210

    

    imagershujuMed = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-ImagerWuWidth/2, SCREEN_HEIGHT/2-ImagerWuheight/2, ImagerWuWidth, ImagerWuheight)];

    imagershujuMed.image = [UIImage imageNamed:@"zanwushuju1"];

    imagershujuMed.hidden = YES;

    

    [scrviewll addSubview:imagershujuMed];

    

    

    tiwuxianLabmed = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-TishiLabwidth/2, CGRectGetMaxY(imagershujuMed.frame), TishiLabwidth, 30)];

    tiwuxianLabmed.text = @"暂无数据";

    tiwuxianLabmed.textAlignment = YES;

    tiwuxianLabmed.textColor = RGB(188, 188, 188);

    tiwuxianLabmed.hidden = YES;

    tiwuxianLabmed.font = SYSTEMFONT(TishiLabFont);

    [scrviewll  addSubview:tiwuxianLabmed];

}

//返回上一级界面

-(void)backClickMedicine{

     [self.navigationController popViewControllerAnimated:YES];

}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error

{

        UIAlertView *alterview = [[UIAlertView alloc] initWithTitle:@"" message:[error localizedDescription]  delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];

        [alterview show];

    

}

- (void)webViewDidStartLoad:(UIWebView *)webView

{

    //    [activityIndicatorView startAnimating] ;

    [MBProgressHUD  showHUDAddedTo:self.view animated:YES];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView

{

    //    [activityIndicatorView stopAnimating];

    [MBProgressHUD hideHUDForView:self.view animated:YES];

}

@end

原文地址:https://www.cnblogs.com/gzz2016/p/5203693.html