获取json格式的数据并显示在webview上
2015-09-30 09:25
555 查看
NSURL *url = [NSURLURLWithString:@"http://cst.stu.126.net/u/json/cms/ykt_protocol.json"];
NSData *responseData = [NSDatadataWithContentsOfURL:url];
NSError *jsonError;
id result = [NSJSONSerializationJSONObjectWithData:responseData
options:kNilOptions
error:&jsonError];
NSString *protocolStr = [result
valueForKey:@"protocol"];
[self.protocolWebviewloadHTMLString:protocolStr
baseURL:nil];
// if (!self.loadingMaskView.hidden) {
// [self.loadingMaskView startLoadingWithTip:@"努力载入中..."];
// }
// NSURL *url = [NSURL URLWithString:@"http://cst.stu.126.net/u/json/cms/ykt_protocol.json"];
// NSData *responseData = [NSData dataWithContentsOfURL:url];
// NSError *jsonError;
// id result = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&jsonError];
// NSString *protocolStr = [result valueForKey:@"protocol"];
//
// if(protocolStr){
// [self.loadingMaskView stopLoadingSuccessfully];
// //将协议显示到webView
// //加载URL
// [self.protocolWebview loadHTMLString:protocolStr baseURL:nil];
// }
// else{
// [self.loadingMaskView stopLoadingFailedWithTip:@"点击屏幕,重新加载" reloadable:YES];
// }
//
// if (!self.loadingMaskView.hidden) {
// [self.loadingMaskView startLoadingWithTip:@"努力载入中..."];
// }
// NSString *protocolStr = [EduSystem sharedInstance].protocol;
// if(protocolStr){
// [self.loadingMaskView stopLoadingSuccessfully];
// //将协议显示到webView
// //加载URL
// [self.protocolWebview loadHTMLString:protocolStr baseURL:nil];
// }
// else{
// [self.loadingMaskView stopLoadingFailedWithTip:@"点击屏幕,重新加载" reloadable:YES];
// }
// //先从网络上拿数据,如果有网络,显示网络版,否则显示本地版本协议
// NSURL *url = [NSURL URLWithString:@"http://cst.stu.126.net/u/json/cms/ykt_protocol.json"];
// NSData *responseData = [NSData dataWithContentsOfURL:url];
// NSError *jsonError;
// id result = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&jsonError];
// NSString *protocolStr = [result valueForKey:@"protocol"];
//
// if(!protocolStr){
// //网络未获取到
// Protocol *protocol = [Protocol getProtocolWithType:1];
// protocolStr = [protocol valueForKey:@"content"];
// }
// [self.protocolWebview loadHTMLString:protocolStr baseURL:nil];
NSData *responseData = [NSDatadataWithContentsOfURL:url];
NSError *jsonError;
id result = [NSJSONSerializationJSONObjectWithData:responseData
options:kNilOptions
error:&jsonError];
NSString *protocolStr = [result
valueForKey:@"protocol"];
[self.protocolWebviewloadHTMLString:protocolStr
baseURL:nil];
// if (!self.loadingMaskView.hidden) {
// [self.loadingMaskView startLoadingWithTip:@"努力载入中..."];
// }
// NSURL *url = [NSURL URLWithString:@"http://cst.stu.126.net/u/json/cms/ykt_protocol.json"];
// NSData *responseData = [NSData dataWithContentsOfURL:url];
// NSError *jsonError;
// id result = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&jsonError];
// NSString *protocolStr = [result valueForKey:@"protocol"];
//
// if(protocolStr){
// [self.loadingMaskView stopLoadingSuccessfully];
// //将协议显示到webView
// //加载URL
// [self.protocolWebview loadHTMLString:protocolStr baseURL:nil];
// }
// else{
// [self.loadingMaskView stopLoadingFailedWithTip:@"点击屏幕,重新加载" reloadable:YES];
// }
//
// if (!self.loadingMaskView.hidden) {
// [self.loadingMaskView startLoadingWithTip:@"努力载入中..."];
// }
// NSString *protocolStr = [EduSystem sharedInstance].protocol;
// if(protocolStr){
// [self.loadingMaskView stopLoadingSuccessfully];
// //将协议显示到webView
// //加载URL
// [self.protocolWebview loadHTMLString:protocolStr baseURL:nil];
// }
// else{
// [self.loadingMaskView stopLoadingFailedWithTip:@"点击屏幕,重新加载" reloadable:YES];
// }
// //先从网络上拿数据,如果有网络,显示网络版,否则显示本地版本协议
// NSURL *url = [NSURL URLWithString:@"http://cst.stu.126.net/u/json/cms/ykt_protocol.json"];
// NSData *responseData = [NSData dataWithContentsOfURL:url];
// NSError *jsonError;
// id result = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&jsonError];
// NSString *protocolStr = [result valueForKey:@"protocol"];
//
// if(!protocolStr){
// //网络未获取到
// Protocol *protocol = [Protocol getProtocolWithType:1];
// protocolStr = [protocol valueForKey:@"content"];
// }
// [self.protocolWebview loadHTMLString:protocolStr baseURL:nil];
相关文章推荐
- Android task和back stack详解5任务亲和力及其它
- Android 4.4的栈结构变化
- Android模拟器,手机区别
- 经方败案群崩漏专题1(2015年9月) “崩漏治疗经验”微信语音整理版
- iOS开发-用ZipArchive添加和解压zip包
- 支付宝在ios应用上的开发[转]
- 【投稿】iOS相册Moment功能的优化方案
- UIAPPlicationMain() 函数详解 (一个应用程序的启动过程)
- swift基础篇:视图控制器UIViewControler
- Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
- iOS开发之应用内检测手机锁屏,解锁状态
- 源码推荐(9.30):iOS 9 新特性的代码示例,Crash捕捉 崩溃捕捉
- iOS 程序启动顺序
- iOS讲解迷惑深入浅出之懒加载
- iOS8设置应用图标红点的权限问题
- Android手机联系人变化监听
- iOS开发之时间格式的转化
- CocosPods安装和使用教程
- 谷歌称Android活跃用户总数已达14亿人
- WWDC2014之iOS使用动态库