iOS开发常用的第三方类库
Reachability 检测网络连接
ASIHTTPRequest 网络请求
MBProgressHUD 提示效果
SVProgressHUD 提示效果
ZAActivityBar 提示效果
SBJson JSON解析
JSONKit JSON解析
SDWebImage 图片异步加载及缓存
UIActivityIndicator-for-SDWebImage 为SDWebImage显示加载效果
UIImage+Resize 调整图片大小
ImageCacheResize 异步加载图片、缓存及调整大小
EGOTableViewPullRefresh 下拉刷新
PullToRefresh 下拉刷新
STableViewController 下拉刷新、上拉加载更多
SVPullToRefresh 下拉刷新、上拉加载更多
CMPopTipView 提示信息
PrettyKit
MGBox2
Nimbus
FlatUIKit
MUKMediaGallery
PTShowcaseViewController
MWPhotoBrowser
ios-image-filters
PDF Reader Core for iOS
DTCoreText
FTCoreText
CoreTextWrapper
Base64
RNCryptor
在iOS开发中不可避免的会用到一些第三方类库,它们提供了很多实用的功能,使我们的开发变得更有效率;同时,也可以从它们的源代码中学习到很多有用的东西。
Reachability 检测网络连接
用来检查网络连接是否可用:包括WIFI和WWAN(3G/EDGE/CDMA等)两种工作模式。
可以从Apple网站下载到:http://developer.apple.com/library/ios/#samplecode/Reachability/History/History.html#//apple_ref/doc/uid/DTS40007324-RevisionHistory-DontLinkElementID_1。
现在有更好的替代品:https://github.com/tonymillion/Reachability,比Apple提供的兼容性更好,而且更加好用,更具体的使用方法请看它提供的例子。
1 2 3 4 5 6 7 8 9 | Reachability* reach = [Reachability reachabilityWithHostname:@www.google.com]; reach.reachableBlock = ^(Reachability*reach) { NSLog(@网络可用!); }; reach.unreachableBlock = ^(Reachability*reach) { NSLog(@网络不可用!); }; // 开始监听 [reach startNotifier]; |
ASIHTTPRequest 网络请求
ASIHTTPRequest是对CFNetwork API的一个包装,它提供了一套更加简洁的API,使用起来也更加简单。
官方网站:http://allseeing-i.com/ASIHTTPRequest/
GitHub:https://github.com/pokeb/asi-http-request
它不仅仅支持基本的HTTP请求,而且支持基于REST的服务(GET/POST/PUT/DELETE)。
最让人喜欢的是,它支持block语法:
1 2 3 4 5 6 7 8 9 10 11 12 13 | NSURL *url = [NSURL URLWithString:@ http://allseeing-i.com ]; __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setCompletionBlock:^{ // Use when fetching text data NSString *responseString = [request responseString]; // Use when fetching binary data NSData *responseData = [request responseData]; }]; [request setFailedBlock:^{ NSError *error = [request error]; }]; [request startAsynchronous]; |
它的ASIFormDataRequest子类可以横容易的提交表单数据和文件:
1 2 3 4 5 6 7 8 | ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; [request setPostValue:@Ben forKey:@first_name]; [request setPostValue:@Copsey forKey:@last_name]; // Upload a file on disk [request setFile:@/Users/ben/Desktop/ben.jpg withFileName:@myphoto.jpg andContentType:@image/jpeg forKey:@photo]; // Upload an NSData instance [request setData:imageData withFileName:@myphoto.jpg andContentType:@image/jpeg forKey:@photo]; |
详细的使用方法请下载相应的源代码及例子,或者从官方的使用说明http://allseeing-i.com/ASIHTTPRequest/How-to-use开始。
MBProgressHUD 提示效果
支持各种状态加载的提示效果,以及带进度的提示效果。
GitHub:https://github.com/matej/MBProgressHUD
一般会在.m文件实现MBProgressHUDDelegate协议,并声明HUD变量:
1 2 3 4 5 6 7 8 9 10 11 12 | @interface SampleViewController ()MBProgressHUDDelegate> { MBProgressHUD *HUD; } #pragma mark - #pragma mark MBProgressHUDDelegate methods - (void)hudWasHidden:(MBProgressHUD *)hud { // Remove HUD from screen when the HUD was hidded [HUD removeFromSuperview]; HUD = nil; } |
在执行某个异步请求时开始调用:
1 2 3 4 5 | HUD = [MBProgressHUD showHUDAddedTo:self.webView animated:YES]; HUD.labelText = @正在请求...; // mode参数可以控制显示的模式 //HUD.mode = MBProgressHUDModeText; HUD.delegate = self; |
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)