另一个显示图片的图片浏览器。
_simplePhotoBrowser = [[DXPhotoBrowser alloc] initWithPhotosArray:@[ id<DXPhoto> ]];
[_simplePhotoBrowser showPhotoAtIndex:someIndexWithThePhotos withThumbnailImageView:someImageViewOrNil];
id<DXPhoto>
必须的协议方法 loadImageWithProgressBlock:completionBlock:
可以实现如下
- (void)loadImageWithProgressBlock:(DXPhotoProgressBlock)progressBlock completionBlock:(DXPhotoCompletionBlock)completionBlock {
__weak typeof(self) wself = self;
SDWebImageCompletionWithFinishedBlock finishBlock = ^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (completionBlock) {
completionBlock(wself, image);
}
};
_operation = [[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:_imageURL] options:1 progress:nil completed:finishBlock];
}
- (void)cancelLoadImage {
[_operation cancel];
_operation = nil;
}
有关更多详细信息,最佳实践,请查看 DXSimplePhoto.
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
iOS '~6.0'
DXPhotoBrowser 通过 CocoaPods 提供。要安装它,只需在 Podfile 中添加以下行
pod "DXPhotoBrowser"
DXPhotoBrowser 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。