`
473687880
  • 浏览: 478354 次
文章分类
社区版块
存档分类
最新评论

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;

    请求完成时隐藏提示效果:

    1
    [HUD hide:YES];

    对于同步方法一般都是用showWhileExecuting方法,方法执行完成之后会自动隐藏提示效果:

    1
    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];

    SVProgressHUD 提示效果

    GitHub:https://github.com/samvermette/SVProgressHUD

    SVProgressHUD和MBProgressHUD效果差不多,不过不需要使用协议,同时也不需要声明实例。

    直接通过类方法进行调用即可:

    1
    [SVProgressHUD method]

    可以使用以下方法来显示状态:

    1
    2
    3
    4
    + (void)show;
    + (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
    + (void)showWithStatus:(NSString*)string;
    + (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType;

    如果需要明确的进度,则使用以下方法:

    1
    2
    3
    + (void)showProgress:(CGFloat)progress;
    + (void)showProgress:(CGFloat)progress status:(NSString*)status;
    + (void)showProgress:(CGFloat)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;

    通过dismiss方法来隐藏提示:

    1
    + (void)dismiss;

    另外提供了以下方法用于显示状态,并在1秒后自动隐藏提示(使用的图标来源于Glyphish:http://www.glyphish.com/):

    1
    2
    3
    + (void)showSuccessWithStatus:(NSString*)string;
    + (void)showErrorWithStatus:(NSString *)string;
    + (void)showImage:(UIImage*)image status:(NSString*)string;// use 28x28 white pngs

    ZAActivityBar 提示效果

    GitHub:https://github.com/zacaltman/ZAActivityBar

    ZAActivityBar和SVProgressHUD非常相似,它提供了更加简洁的API来显示提示效果。

    ZAActivityBar使用的动画效果来源于ZKBounceAnimation(https://github.com/khanlou/SKBounceAnimation),成功、失败的状态图标来源于Pictos(http://pictos.cc/)。

    显示加载状态:

    1
    [ZAActivityBar showWithStatus:@"加载中..."];

    显示成功、失败状态:

    1
    2
    [ZAActivityBar showSuccessWithStatus:@"成功!"];
    [ZAActivityBar showErrorWithStatus:@"失败!"];

    隐藏提示:

    1
    [ZAActivityBar dismiss];

    SBJson JSON解析

    官方:http://sbjson.org/

    GitHub:https://github.com/stig/json-framework

    API使用起来稍显繁琐,特别是初始化的时候:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    @interface TestViewController ()<SBJsonStreamParserAdapterDelegate> {
    SBJsonStreamParser *parser;
    SBJsonStreamParserAdapter *adapter;
    }
    // 冗长的初始化方法足以吓到一大片人
    - (void)initSBJSON
    {
    // We don't want *all* the individual messages from the
    // SBJsonStreamParser, just the top-level objects. The stream
    // parser adapter exists for this purpose.
    adapter = [[SBJsonStreamParserAdapter alloc] init];
    // Set ourselves as the delegate, so we receive the messages
    // from the adapter.
    adapter.delegate = self;
    // Create a new stream parser..
    parser = [[SBJsonStreamParser alloc] init];
    // .. and set our adapter as its delegate.
    parser.delegate = adapter;
    // Normally it's an error if JSON is followed by anything but
    // whitespace. Setting this means that the parser will be
    // expecting the stream to contain multiple whitespace-separated
    // JSON documents.
    parser.supportMultipleDocuments = YES;
    }
    #pragma mark SBJsonStreamParserAdapterDelegate methods
    - (void)parser:(SBJsonStreamParser *)parser foundArray:(NSArray *)array {
    [NSExceptionraise:@"unexpected"format:@"Should not get here"];
    }
    - (void)parser:(SBJsonStreamParser *)parser foundObject:(NSDictionary *)dict {
    NSLog(@"SBJson parser foundObject");
    // 处理返回的数据
    }
    // 使用ASIHTTPRequest请求测试
    - (void) loadData {
    __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setRequestMethod:@"POST"];
    [request setCompletionBlock:^{
    // Use when fetching text data
    //NSString *responseString = [request responseString];
    // Use when fetching binary data
    NSData *responseData = [request responseData];
    NSLog(@"Connection didReceiveData of length: %u", responseData.length);
    // Parse the new chunk of data. The parser will append it to
    // its internal buffer, then parse from where it left off in
    // the last chunk.
    SBJsonStreamParserStatus status = [parser parse:responseData];
    if(status == SBJsonStreamParserError) {
    NSLog(@"Parser error: %@", parser.error);
    }elseif(status == SBJsonStreamParserWaitingForData) {
    NSLog(@"Parser waiting for more data");
    }
    }];
    [request setFailedBlock:^{
    NSError *error = [request error];
    NSLog(@"failed - %@ %@", [error localizedDescription], error);
    }];
    [request startAsynchronous];
    }

    JSONKit JSON解析

    GitHub:https://github.com/johnezang/JSONKit

    提供比SBJson更优异的性能以及更加简便的使用方法,但是中文最好使用utf-8格式(\uXXXX),否则容易造成乱码。

    API调用起来非常简单,省去了SBJson那么一大堆的方法:

    1
    2
    JSONDecoder* decoder = [[JSONDecoder alloc] initWithParseOptions:JKParseOptionNone];
    id result = [decoder objectWithData:jsonData];

    详细的使用方法请看它的GitHub主页。

    SDWebImage 图片异步加载及缓存

    SDWebImage用于异步下载网络上的图片,并支持对图片的缓存等。

    多数情况下是使用UIImageView+WebCache为UIImageView异步加载图片:

    1
    2
    3
    4
    #import <SDWebImage/UIImageView+WebCache.h>
    // ...
    [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
    placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

    需要注意的是,pladeholderImage的大小一定要大于UIImageView的大小,否则可能不显示placeholderImage图片。

    它还支持block语法用于在加载完成时做一些操作:

    1
    2
    3
    [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
    placeholderImage:[UIImage imageNamed:@"placeholder.png"]
    completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {... completion code here ...}];

    SDWebImage并不局限于UIImageView上,使用SDWebImageManager完成更多的操作:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    SDWebImageManager *manager = [SDWebImageManager sharedManager];
    [manager downloadWithURL:imageURL
    options:0
    progress:^(NSUInteger receivedSize,longlongexpectedSize)
    {
    // 下载进度
    }
    completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)
    {
    if(image)
    {
    // 下载完成
    }
    }];

    或者使用Image Downloader也是一样的效果:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [SDWebImageDownloader.sharedDownloader downloadImageWithURL:imageURL
    options:0
    progress:^(NSUInteger receivedSize,longlongexpectedSize)
    {
    // 进度
    }
    completed:^(UIImage *image, NSData *data, NSError *error,BOOLfinished)
    {
    if(image && finished)
    {
    // 下载完成
    }
    }];

    UIActivityIndicator-for-SDWebImage 为SDWebImage显示加载效果

    GitHub:https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage

    用于为SDWebImage在UIImageView加载图片时,显示加载效果(UIActivityIndicatorView实现),它提供以下方法:

    1
    2
    3
    4
    5
    6
    7
    - (void)setImageWithURL:(NSURL *)url usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
    - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;

    UIImage+Resize 调整图片大小

    GitHub:https://github.com/coryalder/UIImage_Resize

    提供多种方法为图片设置透明度、圆角、裁剪、调整大小等:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    - (UIImage *)imageWithAlpha;
    - (UIImage *)transparentBorderImage:(NSUInteger)borderSize;
    - (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize;
    - (UIImage *)croppedImage:(CGRect)bounds;
    - (UIImage *)thumbnailImage:(NSInteger)thumbnailSize
    transparentBorder:(NSUInteger)borderSize
    cornerRadius:(NSUInteger)cornerRadius
    interpolationQuality:(CGInterpolationQuality)quality;
    - (UIImage *)resizedImage:(CGSize)newSize
    interpolationQuality:(CGInterpolationQuality)quality;
    - (UIImage *)
    resizedImageWithContentMode:(UIViewContentMode)contentMode
    bounds:(CGSize)bounds
    interpolationQuality:(CGInterpolationQuality)quality;

    更详细使用见:http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

    ImageCacheResize 异步加载图片、缓存及调整大小

    GitHub:https://github.com/toptierlabs/ImageCacheResize

    整合了SDWebImage和UIImage+Resize的功能,用于图片的异步加载、缓存、以及下载完成后调整大小并显示在UIImageView上。

    提供了以下API用于加载图片以及加载完成后调整图片大小:

    1
    2
    3
    4
    5
    6
    - (void)setImageWithURL:(NSURL *)url andCropToBounds:(CGRect)bounds;
    - (void)setImageWithURL:(NSURL *)url andResize:(CGSize)size withContentMode:(UIViewContentMode)mode;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder andCropToBounds:(CGRect)bounds;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options andResize:(CGSize)size;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options andResize:(CGSize)size withContentMode:(UIViewContentMode)mode;
    - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options andCropToBounds:(CGRect)bounds;

    使用方法和SDWebImage一样简单,如以下官方例子:

    1
    2
    [imageview setImageWithURL:[NSURL URLWithString:@"http://t0.gstatic.com/images?q=tbn:ANd9GcQfraHpiabjEY8iDdBe9OUQYHMtwfuAv9ZRR0RYKuoVF_EpE8Fp5A"] andResize:CGSizeMake(30, 30) withContentMode:UIViewContentModeScaleAspectFit]; // 按比例缩放
    [imageview setImageWithURL:[NSURL URLWithString:@"http://t0.gstatic.com/images?q=tbn:ANd9GcQfraHpiabjEY8iDdBe9OUQYHMtwfuAv9ZRR0RYKuoVF_EpE8Fp5A"] andCropToBounds:CGRectMake(0, 0, 100, 100)]; // 裁剪成100x100大小

    EGOTableViewPullRefresh 下拉刷新

    GitHub:https://github.com/enormego/EGOTableViewPullRefresh

    这是最早出现的为UITableView提供下拉刷新功能的类库,使用起来稍显麻烦,需要实现诸多协议(代码取自官方DEMO):

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    #import "EGORefreshTableHeaderView.h"
    @interface RootViewController : UITableViewController <EGORefreshTableHeaderDelegate, UITableViewDelegate, UITableViewDataSource>{
    EGORefreshTableHeaderView *_refreshHeaderView;
    // 是否正在加载中
    BOOL_reloading;
    }
    - (void)viewDidLoad {
    [super viewDidLoad];
    if(_refreshHeaderView == nil) {
    EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.view.frame.size.width, self.tableView.bounds.size.height)];
    view.delegate = self;
    [self.tableView addSubview:view];
    _refreshHeaderView = view;
    [view release];
    }
    // 更新最后加载时间
    [_refreshHeaderView refreshLastUpdatedDate];
    }
    #pragma mark -
    #pragma mark Data Source Loading / Reloading Methods
    - (void)reloadTableViewDataSource{
    // 在这里加入代码用于获取数据
    _reloading = YES;
    }
    - (void)doneLoadingTableViewData{
    // 数据加载完成时调用这个方法
    _reloading = NO;
    [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.tableView];
    }
    #pragma mark -
    #pragma mark UIScrollViewDelegate Methods
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
    }
    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    [_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];
    }
    #pragma mark -
    #pragma mark EGORefreshTableHeaderDelegate Methods
    - (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{
    [self reloadTableViewDataSource];
    [self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:3.0];
    }
    - (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{
    return_reloading;// should return if data source model is reloading
    }
    - (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{
    return[NSDate date];// should return date data source was last changed
    }

    PullToRefresh 下拉刷新

    GitHub:https://github.com/leah/PullToRefresh

    PullToRefresh提供比EGOTableViewPullRefresh更加简单的使用方法,只要继承自PullRefreshTableViewController,再实现refresh方法即可:

    1
    2
    3
    4
    5
    6
    - (void)refresh {
    // 加载数据
    [self.tableView reloadData];// 重新载入UITableView
    [self stopLoading];//停止动画
    }

    STableViewController 下拉刷新、上拉加载更多

    GitHub:https://github.com/shiki/STableViewController

    STableViewController比PullToRefresh多了一个上拉加载更多功能,使用上也差不多简单,需要继承自STableViewController,再实现一些方法:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    - (void) viewDidLoad
    {
    [super viewDidLoad];
    self.title = @"STableViewController Demo";
    [self.tableView setBackgroundColor:[UIColor lightGrayColor]];
    // 需要创建两个自定义视图用于显示"下拉刷新"、"上拉加载更多"
    self.headerView = headerView;
    self.footerView = footerView;
    }
    #pragma mark - Pull to Refresh
    - (void) pinHeaderView
    {
    [super pinHeaderView];
    // 下拉刷新视图显示一些加载动画
    }
    - (void) unpinHeaderView
    {
    [super unpinHeaderView];
    // 下拉刷新视图停止动画
    }
    - (void) headerViewDidScroll:(BOOL)willRefreshOnRelease scrollView:(UIScrollView *)scrollView
    {
    // 下拉刷新视图显示状态信息
    if(willRefreshOnRelease)
    //hv.title.text = @"松开后刷新...";
    else
    //hv.title.text = @"下拉刷新...";
    }
    - (BOOL) refresh
    {
    if(![super refresh])
    returnNO;
    // 下拉刷新加载数据
    [self performSelector:@selector(addItemsOnTop) withObject:nil afterDelay:2.0];
    returnYES;
    }
    #pragma mark - Load More
    - (void) willBeginLoadingMore
    {
    // 上拉加载更多视图加载动画
    }
    - (void) loadMoreCompleted
    {
    [super loadMoreCompleted];
    // 上拉加载更多视图停止动画
    if(!self.canLoadMore) {
    //没有更多数据的时候执行代码...
    }
    }
    - (BOOL) loadMore
    {
    if(![super loadMore])
    returnNO;
    // 上拉加载更多数据
    [self performSelector:@selector(addItemsOnBottom) withObject:nil afterDelay:2.0];
    returnYES;
    }
    //
    - (void) addItemsOnTop
    {
    // 加载数据...
    [self.tableView reloadData];
    // 数据加载完成通知上拉视图
    [self refreshCompleted];
    }
    - (void) addItemsOnBottom
    {
    // 加载更多数据...
    [self.tableView reloadData];
    // 通过判断设置是否可以加载更多
    //self.canLoadMore = NO;
    // 数据加载完成通知下拉视图
    [self loadMoreCompleted];
    }

    SVPullToRefresh 下拉刷新、上拉加载更多

    GitHub:https://github.com/samvermette/SVPullToRefresh

    包含SVPullToRefresh + SVInfiniteScrolling为UITableView提供下拉刷新、上拉加载更多功能。

    使用起来也相当简单,只要在UITableViewController里实现以下方法:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    - (void)viewDidLoad {
    [super viewDidLoad];
    __weak SVViewController *weakSelf = self;
    // 设置下拉刷新
    [self.tableView addPullToRefreshWithActionHandler:^{
    [weakSelf insertRowAtTop];
    }];
    // 设置上拉加载更多
    [self.tableView addInfiniteScrollingWithActionHandler:^{
    [weakSelf insertRowAtBottom];
    }];
    }
    - (void)viewDidAppear:(BOOL)animated {
    [tableView triggerPullToRefresh];
    }
    - (void)insertRowAtTop {
    // 获取数据....
    // 停止动画
    [self.tableView.pullToRefreshView stopAnimating];
    }
    - (void)insertRowAtBottom {
    // 获取数据....
    // 停止动画
    [weakSelf.tableView.infiniteScrollingView stopAnimating];
    }

    CMPopTipView 提示信息

    GitHub:https://github.com/chrismiles/CMPopTipView

    CMPopTipView用于在一些视图上显示提示信息:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    self.tipView = [[CMPopTipView alloc] initWithMessage:@"提示消息"];
    self.tipView.delegate = self;
    [self.tipView presentPointingAtView:anyButton inView:self.view animated:YES];// 点击按钮显示
    [self.tipView presentPointingAtBarButtonItem:barButtonItem animated:YES];// 点击导航栏按钮显示
    #pragma mark CMPopTipViewDelegate methods
    - (void)popTipViewWasDismissedByUser:(CMPopTipView *)popTipView {
    // 清理资源
    self.tipView = nil;
    }

    PrettyKit

    GitHub:https://github.com/vicpenap/PrettyKit

    定制了一些UI组件如UITableViewCell、UINavigationBar、UITabBar、UIToolBar等,比系统自带的更加美观。

    MGBox2

    GitHub:https://github.com/sobri909/MGBox2

    提供一些定制的UI组件可以更简单快速的创建表格、网格布局,以及丰富的文本呈现,基于block的事件机制等,包含:MGBox、MGTableBox、MGTableBoxStyled、MGScrollView、MGButton、MGEvents、MGEasyFrame、MGLine等,其中MGBox还支持screenshot方法用于截图。

    Nimbus

    GitHub:https://github.com/jverkoey/nimbus

    著名的框架,提供了一套非常丰富的UI组件,可以使开发变得更加简单、有效率。

    FlatUIKit

    GitHub:https://github.com/Grouper/FlatUIKit

    扁平化设计的UI组件,类似于WP或者iOS7的风格。

    MUKMediaGallery

    GitHub:https://github.com/muccy/MUKMediaGallery

    媒体库效果,支持图片、视频及音频。

    PTShowcaseViewController

    GitHub:https://github.com/exalted/PTShowcaseViewController

    同样是一个媒体库效果,支持的格式更多,包括:图片、视频、PDF等.

    MWPhotoBrowser

    GitHub:https://github.com/mwaterfall/MWPhotoBrowser

    图片展示效果,支持本地及远程的图片,使用也比较简单,只要实现MWPhotoBrowserDelegate协议:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    @interface TestViewController ()<MWPhotoBrowserDelegate>
    {
    NSArray *_photos;
    }
    -(void) doAction {
    NSMutableArray *photos = [[NSMutableArray alloc] init];
    for(...) {
    MWPhoto* photo = [MWPhoto photoWithURL:[NSURL URLWithString:url]];// 设置图片地址
    photo.caption = description;// 设置描述
    [photos addObject:photo];
    }
    _photos = photos;
    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
    browser.displayActionButton = YES;
    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:browser];
    nc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:nc animated:YES];
    }
    #pragma mark - MWPhotoBrowserDelegate
    - (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return_photos.count;
    }
    - (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    if(index < _photos.count)
    return[_photos objectAtIndex:index];
    returnnil;
    }

    ios-image-filters

    GitHub:https://github.com/esilverberg/ios-image-filters

    提供多种图片滤镜效果。

    PDF Reader Core for iOS

    GitHub:https://github.com/vfr/Reader

    PDF阅读器核心。

    DTCoreText

    GitHub:https://github.com/Cocoanetics/DTCoreText

    支持富文本的显示如HTML。

    FTCoreText

    GitHub:https://github.com/FuerteInternational/FTCoreText

    富文本视图

    CoreTextWrapper

    GitHub:https://github.com/akosma/CoreTextWrapper

    支持多列的文本视图

    Base64

    GitHub:https://github.com/nicklockwood/Base64

    提供对字符串的Base64编码

    RNCryptor

    GitHub:https://github.com/rnapier/RNCryptor

    提供AES加密方法

    分享到:
    评论

    相关推荐

      ios开发常用第三方类库集合

      整理的一些市面上常见的第三方类库,快速集成可以方便开发,这些都是大家常用的。 里面包含: GTM 各种加密 ASIHttp http请求 KissXml xml解析 json oc版 json cpp版 Reachabiliy 网络状态判断 libcurl c语言静态...

      ios开发常用的第三方类库

      ios开发常用的第三方类库,大部分的ios开发中都会用到的第三方开源的类库 如数据库操作,xml解析等等,希望对大家有所帮助

      iOS常用第三方类库 - CocoaChina 苹果开发中文站 - 最热的iPhone开发社区 最热的苹果开发社区 最热的iPa

      iOS常用第三方类库 - CocoaChina 苹果开发中文站 - 最热的iPhone开发社区 最热的苹果开发社区 最热的iPad开发社区1

      iOS开发第三方类库SBJson.zip

      iOS开发 xcode 网站解析 第三方类库 SBJson

      iOS开发常用的第三方库

      iOS开发常用的第三方库,刷新、网络请求、自动适配等等

      ios的第三方类库FMDB打包下载

      在ios开发中,除了使用自带的例如sqlite3_open这类自带的方法使用数据库,还可以使用这个第三方类库

      ios GDataXML

      ios开发对XML解析需要用到的第三方类库CDataXML

      第三方操作数据库sqlite的类库 FMDB

      简化对sqlite的操作,更加方便我们的开发,使用起来简单。

      iOS开发中常见的解析XML的类库以及简要安装方法

      在iPhone开发中,XML的解析有很多选择,iOS SDK提供了NSXMLParser和libxml2两个类库,另外还有很多第三方类库可选,例如TBXML、TouchXML、KissXML、TinyXML和GDataXML。问题是应该选择哪一个呢? 解析 XML 通常有两...

      iOS-BaseArch:iOS开发基础架构

      第三方类库: AFNetworking Realm MOAspects JSONModel AsyncDisplayKit 使用cocoapod 管理第三方类库。 项目架构: 图片组织: 图片位于Images.xcassets中 Login (有关登录的图片) Navigation (导航栏图片) ...

      iOS开发中的神兵利器 [2021版]

      手把手学习iOS开发中的强大的第三方类库,详细讲解Github中的热门的iOS开发开源项目。助您快速、优雅地解决iOS开发中棘手的业务需求!   【课程特点】  1、代码逐行讲解 2、语言简洁、精练、瞄准问题的核心所在,...

      好用的第三方库AFNetworking

      iOS开发必备第三方库,简单实用,网络请求快,解析出来的数据可以戒指实用.

      iOS开发之抽屉效果实现

      说道抽屉效果在iOS中比较有名的第三方类库是PPRevealSideViewController。一说到第三方类库自然而然的想到我们的CocoaPods,的博客中用CocoaPods引入PPRevealSideViewController,然后在我们的工程中以代码结合...

      最新的CocoaPods安装教程

      当你开发iOS应用时,会经常使用到很多第三方开源类库,比如JSONKit,AFNetWorking等等。可能某个类库又用到其他类库,所以要使用它,必须得另外下载其他类库,而其他类库又用到其他类库,“子子孙孙无穷尽也”,这...

      GDataXML类

      ios开发对XML解析需要用到的第三方类库GDataXML,包含GDataXMLNode.h 、GDataXMLNode.m(备注使用mac压缩承德 文档 归档.zip)

      CocoaPods安装和使用教程

      当你开发iOS应用时,会经常使用到很多第三方开源类库,比如JSONKit,AFNetWorking等等。可能某个类库又用到其他类库,所以要使用它,必须得另外下载其他类库,而其他类库又用到其他类库,“子子孙孙无穷尽也”,这...

      IOS项目开发便捷类

      自己开发中遇到总结类库使用,方法使用,项目构建,好分必有好资源

      React Native 开发指南_中文扫描完整版

      9.4 探索第三方依赖 180 9.5 响应式设计与字体尺寸 180 9.6 小结及任务 183 第10章 部署至iOS 应用商店 184 10.1 准备Xcode 工程 184 10.2 上传应用 192 10.3 使用TestFlight 进行Beta 测试 199 10.4 提交...

    Global site tag (gtag.js) - Google Analytics