ProgressHUD 的使用
2015-07-15 10:26
69 查看
一、主要方法简介:
// 网络请求开始之前,先给用户提示,网络正在加载中... [ProgressHUDshow:@"加载中..."Interaction:YES]; // 取消风火轮旋转 [ProgressHUD dismiss]; [ProgressHUD showSuccess:@"数据已经为您请求成功" Interaction:YES]; [ProgressHUD showError:@"大爷,你的网不好,你看毛线啊" Interaction:YES];
二、代码示例:
// // RootViewController.m // ProgressHUD_test // // #import "RootViewController.h" #import "AFHTTPRequestOperationManager.h" #import "ProgressHUD.h" @interface RootViewController () @end @implementation RootViewController - (void)viewDidLoad { [super viewDidLoad]; // 网络请求开始之前,先给用户提示,网络正在加载中... [ProgressHUD show:@"加载中..." Interaction:YES]; // 初始化 AFHTTPRequestOperationManager,不需要alloc AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; /* 第一个参数:接口地址 第二个参数:传递参数时要用到,GET请求不需要传递参数,所以此处写nil就可以,当POST请求的时候,需要在接口后边拼接参数,把参数以 key : Value 的形式封装到字典里,AFNetworking为自动给为我们把需要传递的参数拼接到我们的接口后边。 第三个参数:是网络请求成功的回调方法,responseObject 参数是 请求到得 JSON 数据 第四个参数:是网络请求失败的时候的回调方法,error 参数,是网络请求失败的信息 */ [manager GET:@"http://api.smzdm.com/v1/util/banner?s=55691368cf612709254&type=home&v=5.6.1&f=iphone" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { [ProgressHUD showSuccess:@"数据已经为您请求成功" Interaction:YES]; // 取消风火轮旋转 // [ProgressHUD dismiss]; NSLog( @"%@", responseObject ) ; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { [ProgressHUD showError:@"大爷,你的网不好,你看毛线啊" Interaction:YES]; NSLog( @"error:%@", error ) ; }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #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
三、注意事项:
这个第三方只能用在 view 上相关文章推荐
- XMPP之安装mySQL--Mac OS(一)
- 电感,磁珠,0欧姆电阻
- Linux 信号(二)—— signal 函数
- 黑马程序员------C语言中scanf的使用
- 把Tomcat设为自启动Windows服务
- android network develop(2)----network status check
- 实现对象缓存框架二、ZSYCache
- 在二进制树中的节点之间的最大距离(最长路径树)——递归解决方案
- jQuery中(function($){})(jQuery)详解
- 如何停止mongo
- ListView缓存机制
- Dash---程序员的好帮手
- 7月上旬国内网站流量统计TOP5:新浪跻身五强居四
- Android电子书项目实训【服务器JDBC部分】【2】
- matlab 寻找二进制图像边缘
- android AsyncTask介绍
- android AsyncTask介绍 分类: Android 2015-07-15 10:24 6人阅读 评论(0) 收藏
- eclipse 点击 open Implementation就退出eclipse
- 002.Kafka的Java访问
- tsung测试tigase结果说明