iOS网络编程-MBProgressHUD等待指示器
来源:互联网 发布:工信部证书有用吗 知乎 编辑:程序博客网 时间:2024/04/30 20:56
第三方的等待指示器,MBProgressHUD就是第三方提供的等待指示器框架。下面是MBProgressHUD提供的等待指示器样式,它们基本可以分为:未知结束时间和已知结束时间两大类等待指示器,在MBProgressHUD中可以为等待指示器添加标签和详细标签
MBProgressHUD的下载地址是https://github.com/matej/MBProgressHUD,我们将下载的源文件中的MBProgressHUD.h和MBProgressHUD.m拷贝到自己的工程中,MBProgressHUD依赖的框架有:Foundation.framework、UIKit.framework和CoreGraphics.framework,我们需要将这些框架添加到工程中。
我们为应用添加MBProgressHUD等待指示器,修改主视图控制器MasterViewController.m的startRequest方法代码如下,注意加粗部分:
- -(void)startRequest
- {
- //初始化MBProgressHUD
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- hud.mode = MBProgressHUDModeCustomView;
- hud.labelText = @”Loading”;
- NSString *strURL = [[NSString alloc]
- initWithFormat:@”http://iosbook3/mynotes/webservice.php”];
- NSURL *url = [NSURL URLWithString:[strURL URLEncodedString]];
- NSString *post;
- if (action == ACTION_QUERY) {//查询处理
- post = [NSString stringWithFormat:@"email=%@&type=%@&action=%@",
- @"<你的iosbook1.com用户邮箱>",@"JSON",@"query"];
- } else if (action == ACTION_REMOVE) {//删除处理
- NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
- NSMutableDictionary* dict = self.listData[indexPath.row];
- post = [NSString stringWithFormat:@"email=%@&type=%@&action=%@&id=%@",
- @"<你的iosbook1.com用户邮箱>",@"JSON",@"remove",[dict objectForKey:@"ID"]];
- }
- NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding];
- NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
- [request setHTTPMethod:@"POST"];
- [request setHTTPBody:postData];
- NSURLConnection *connection = [[NSURLConnection alloc]
- initWithRequest:request delegate:self];
- if (connection) {
- _datas = [NSMutableData new];
- }
- }
- -(void) connection:(NSURLConnection *)connection didFailWithError: (NSError *)error {
- NSLog(@”%@”,[error localizedDescription]);
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- }
- - (void) connectionDidFinishLoading: (NSURLConnection*) connection {
- NSLog(@”请求完成…”);
- NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:_datas
- options:NSJSONReadingAllowFragments error:nil];
- if (action == ACTION_QUERY) {//查询处理
- [self reloadView:dict];
- } else if (action == ACTION_REMOVE) {//删除处理
- NSString *message = @”操作成功。”;
- NSNumber *resultCodeObj = [dict objectForKey:@"ResultCode"];
- if ([resultCodeObj integerValue] < 0) {
- message = [resultCodeObj errorMessage];
- }
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@”提示信息”
- message:message
- delegate:nil
- cancelButtonTitle:@”OK”
- otherButtonTitles: nil];
- [alertView show];
- //重新查询
- action = ACTION_QUERY;
- [self startRequest];
- }
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- }
- iOS网络编程-MBProgressHUD等待指示器
- iOS网络编程-MBProgressHUD等待指示器
- iOS网络编程-MBProgressHUD等待指示器
- iOS网络编程-MBProgressHUD等待指示器
- iOS网络编程-MBProgressHUD等待指示器
- MBProgressHUD等待指示器
- 使用开源库 MBProgressHUD 等待指示器
- ios 指示器MBProgressHUD 的使用
- 指示器MBProgressHUD
- ASIHTTPRequest 状态栏网络等待指示器
- IOS网络指示器实例
- iOS自定义加载等待视图-MBProgressHUD
- iOS 一个带动画的等待指示器
- ios使用网络活动指示器
- iOS: 下载等待画面open source lib - MBProgressHUD
- iOS开发之自定义加载等待框(MBProgressHUD)
- IOS--─自定义加载等待框(MBProgressHUD)
- 第三方框架 MBProgressHUD 指示器
- 钩子函数与回调函数
- BluetoothAdapter ;BluetoothDevice;BluetoothSocket;BluetoothServerSocket;UUID和String转换;
- iOS网络编程实践--蓝牙对等网络通信实例讲解
- ubuntu 安装 搜狗输入法
- 经纬度的最简单获得方法
- iOS网络编程-MBProgressHUD等待指示器
- 手机刷机,FastBoot,S-OOF,SPL
- 全局程序集缓存(GAC)
- ADO.NET(五) 调用存储过程(oracle为例)
- iOS网络编程-ASIHTTPRequest小例子-数据请求队列
- Android UI自定义Spinner下拉框(用popuwindow实现)
- iOS网络编程-ASIHTTPRequest异步请求
- Android学习笔记:文件读取与ListView
- 链表