我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

UI中的网页加载-创新互联

- (void)viewDidLoad {

专注于为中小企业提供网站制作、成都做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业内乡免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了千余家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

  [super viewDidLoad];

  // Do any additional setup after loading the view.

  self.title = @"图片新闻";

  //新建网页视图

  webView = [[UIWebView alloc]initWithFrame:self.view.bounds];

  //网页视图自适应屏幕尺寸

  webView.scalesPageToFit = YES;

  //设置代理

  webView.delegate = self;

  [self.view addSubview:webView];

 

  //加载百度

//    //创建request对象

//    NSMutableURLRequest *mResquest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]];

//    //网页控件加载一个

//    [webView loadRequest:mResquest];

 

  //初始化风火轮

  UIActivityIndicatorView *ac = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

  UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:ac];

  self.navigationItem.rightBarButtonItem = rightItem;

  [self _loadData];

}

- (void)_loadData{

  NSString *filePath = [[NSBundle mainBundle]pathForResource:@"news" ofType:@"html"];

  NSError *error = nil;

  NSString *str = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error];

  NSDictionary *jsonData = [ReturnJson showJson:news_detail];

  NSString *title = [jsonData objectForKey:@"title"];

  NSString *source = [jsonData objectForKey:@"source"];

  NSString *time = [jsonData objectForKey:@"time"];

  NSString *author = [jsonData objectForKey:@"author"];

  NSString *content = [jsonData objectForKey:@"content"];

  NSString *htmlStr = [NSString stringWithFormat:str,title,source,time,content,author];

  [webView loadHTMLString:htmlStr baseURL:nil];

}

#pragma mark-UIWebViewDelegate

//开始加载

- (void)webViewDidStartLoad:(UIWebView *)webView{

  UIActivityIndicatorView *ac = (UIActivityIndicatorView *)self.navigationItem.rightBarButtonItem;

  [ac startAnimating];

}

//结束加载

- (void)webViewDidFinishLoad:(UIWebView *)webView{

  UIActivityIndicatorView *ac = (UIActivityIndicatorView *)self.navigationItem.rightBarButtonItem;

  [ac stopAnimating];

}

//加载出错

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

 

}

- (void)didReceiveMemoryWarning {

  [super didReceiveMemoryWarning];

  // Dispose of any resources that can be recreated.

}

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


文章名称:UI中的网页加载-创新互联
网址分享:http://shouzuofang.com/article/spjhc.html

其他资讯