Update: ELCImagePickerController
2015-04-14 10:22
267 查看
March 3rd, 2011 Posted by: Matt Tuzzolo - posted under:Articles » Featured
I recently spent some time with ELCImagePickerController. For those of you who’ve worked with UIImagePickerController, you might have noticed one of its major drawbacks: you can only select one photo at a time. ELCImagePickerController solves this issue by cloning the UI of UIImagePickerController, but with the added bonus of allowing you to select multiple assets. Collin Ruffenach (@cruffenach), who authored the the first version of the picker, has done an awesome job of making ELCImagePickerController look, feel, and behave like a native image picker. For this post I’m going to go through some recent improvements I made to ELCImagePickerController and pass along some lessons learned from working with the AssetsLibrary Framework.
This is my first foray into the AssetsLibrary Framework which was introduced with iOS 4.0. If you’re not already familiar with the framework, I highly suggest checking out both of these posts:
One of the obvious changes I’ve made to the project is a reorganization of the code. Classes are broken out for clarity as you can see here:
Old Tree:
New Tree:
I’ve also renamed several classes to avoid confusion w/ Apple’s and ELC’s respective classes.
On major change to the project is how you present the new
ELCImagePickerController. This is mainly due to an issue we uncovered
with a redundant call to [super init] which was causing a substantial
memory leak. Here’s the new way of showing the image picker:
One interesting optimization I was able to make was on the loading of large albums which was previously taking several seconds. Since ALAssetGroup uses a block to enumerate assets, I just fire off a reloadTable call after a short delay:
Then when the block is finished enumerating, it’ll call reloadTable as well. On an album with roughly 1500 photos, it was pretty tough to reach the bottom of the tableview before the block finished enumerating. So this is a pretty decent solution to the issue. Originally, I experimented with lazy loading the assets as the user scrolled through the table, but ultimately wasn’t able to get the performance I wanted out of it.
This release of ELCImagePickerController should perform faster, and with a smaller memory footprint than before. I hope you enjoy it.
You can follow me on twitter @matt_tuzzolo or get in touch with us at http://www.elctech.com
ps. for an extra bonus, check out [ELCAsset toggleSelection];
I recently spent some time with ELCImagePickerController. For those of you who’ve worked with UIImagePickerController, you might have noticed one of its major drawbacks: you can only select one photo at a time. ELCImagePickerController solves this issue by cloning the UI of UIImagePickerController, but with the added bonus of allowing you to select multiple assets. Collin Ruffenach (@cruffenach), who authored the the first version of the picker, has done an awesome job of making ELCImagePickerController look, feel, and behave like a native image picker. For this post I’m going to go through some recent improvements I made to ELCImagePickerController and pass along some lessons learned from working with the AssetsLibrary Framework.
This is my first foray into the AssetsLibrary Framework which was introduced with iOS 4.0. If you’re not already familiar with the framework, I highly suggest checking out both of these posts:
Asset Libraries and Blocks in iOS 4
Cloning UIImagePickerController using the Assets Library Framework
These should give you a solid picture of how to work with ALAssetLibrary, ALAssetGroup, and ALAsset.One of the obvious changes I’ve made to the project is a reorganization of the code. Classes are broken out for clarity as you can see here:
Old Tree:
New Tree:
I’ve also renamed several classes to avoid confusion w/ Apple’s and ELC’s respective classes.
On major change to the project is how you present the new
ELCImagePickerController. This is mainly due to an issue we uncovered
with a redundant call to [super init] which was causing a substantial
memory leak. Here’s the new way of showing the image picker:
ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] initWithNibName:@"ELCAlbumPickerController" bundle:[NSBundle mainBundle]];ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController]; [albumController setParent:elcPicker]; [elcPicker setDelegate:self]; ELCImagePickerDemoAppDelegate *app = (ELCImagePickerDemoAppDelegate *)[[UIApplication sharedApplication] delegate]; [app.viewController presentModalViewController:elcPicker animated:YES]; [elcPicker release]; [albumController release]; |
// Show partial list while full list loads [self.tableView performSelector:@selector(reloadData) withObject:nil afterDelay:.5]; |
This release of ELCImagePickerController should perform faster, and with a smaller memory footprint than before. I hope you enjoy it.
You can follow me on twitter @matt_tuzzolo or get in touch with us at http://www.elctech.com
ps. for an extra bonus, check out [ELCAsset toggleSelection];
相关文章推荐
- ELCImagePickerController 选择图片
- ELCImagePickerController 同时选择多张图片时,获取文件名称
- ELCImagePickerController 的集成
- ELCImagePickerController
- DLCImagePickerController
- RSKImageCropViewController与TZImagePickerController
- 如何在ImagePickerController中只显示图片或者视频?(既视频和图片的筛选)
- 使 ZCImagePickerController 支持预览功能
- ELCImagePicker 学习总结(六)
- 横屏下的ImagePickerController
- customImagePickerViewController.overlayView
- QBImagePickerController 下ALAsset ,PHAsset转图片的使用
- ELCImagePicker 学习总结(七)
- 如何在ImagePickerController中只显示图片或者视频
- 不使用UIImagePickerControllerOriginalImage获取相册图片
- IOS - 使用 QBImagePickerController 从系统相册选取多张照片
- 利用UIImagePickerController或者利用UIKit的 UIGraphicsBeginImageContext保存图片
- 在imagePickerController:didFinishPickingMediaWithInfo:方法中presentModalViewController失效怎么办?
- iOS ImagePickerController 入门
- 如何在ImagePickerController中只显示图片或者视频