nek023 / qbimagepicker Goto Github PK
View Code? Open in Web Editor NEWA clone of UIImagePickerController with multiple selection support.
License: MIT License
A clone of UIImagePickerController with multiple selection support.
License: MIT License
Nice Job!
Quick question, if after the user selected images he wants to open the picker again and edit his selection, how is it possible to achieve? (similar to whatsapp?)
Is there a way to give back the picker the PHAsset array?
Also, on another note, is there a way to convert PHAsset to UIImage synchronously?
Thank you
set "maximumNumberOfSelection" crash
imagePickerController.allowsMultipleSelection = YES;
imagePickerController.limitsMaximumNumberOfSelection = YES;
imagePickerController.maximumNumberOfSelection = 10;
photos in album is less than setting, crash to choose last picture.
and, photo setting count and selected Large than one setting, crash to choose the image of the other.
I would like to use your library with a search bar embedded. Is that possible and how ? Thanks
When pick video, if there is only one video in my album, it will crash...
If there are more than one video, it works well
Hi! @questbeat
Can you help me?
Jack
Hi
Can I request a feature to be added so as you can Refresh the tableview for instance when a new photo is taken ?
Thanks,
Michael
Previously there was a method [QBImagePickerController isAccessible]
. But it was removed since about 2.5.0.
How can we detect if imagePicker can be used?
Thank you.
I have noticed that QBImagePicker not has exactly same sorting as in the native iOS photoapp.
Lets say I edit a photo in Camera+ app and save it back to gallery.
In the native photopicker the photo I edited and saved will be down at the bottom since it was the last one I changed. The original will be at its original place according to its creation date.
In QBImagePicker the photo I edited will be just after at it's original according to it's original creation date.
I want to choose video to upload,but the delegate method
- (void)assetCollectionViewController:(QBAssetCollectionViewController *)assetCollectionViewController didFinishPickingAssets:(NSArray *)assets
{
if([self.delegate respondsToSelector:@selector(imagePickerControllerWillFinishPickingMedia:)]) {
[self.delegate imagePickerControllerWillFinishPickingMedia:self];
}
if([self.delegate respondsToSelector:@selector(imagePickerController:didFinishPickingMediaWithInfo:)]) {
NSMutableArray *info = [NSMutableArray array];
for(ALAsset *asset in assets) {
[info addObject:[self mediaInfoFromAsset:asset]];
}
[self.delegate imagePickerController:self didFinishPickingMediaWithInfo:info];
}
}
- (NSDictionary *)mediaInfoFromAsset:(ALAsset *)asset
{
NSMutableDictionary *mediaInfo = [NSMutableDictionary dictionary];
[mediaInfo setObject:[asset valueForProperty:ALAssetPropertyType] forKey:@"UIImagePickerControllerMediaType"];
[mediaInfo setObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]] forKey:@"UIImagePickerControllerOriginalImage"];
[mediaInfo setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:@"UIImagePickerControllerReferenceURL"];
return mediaInfo;
}
The line of code [info addObject:[self mediaInfoFromAsset:asset]];
takes long time because you try to get an UIImage
object from every ALAsset
object in the array. This is on main thread, so it blocks UI after the user click done button.
My suggestion is you just return ALAsset array. Let the delegates do whatever they like. Maybe asynchronous tasks.
I am trying to use this control in my app, In my app i have to upload the selected videos and images to server. when uploading images there is no problem because i can get the raw image from didFinishPickingMediaWithInfo delegate method so i will save that raw image in a particular path then i will send that path to server. But when i am trying upload video file i am facing problem because it does not return uiimagepickercontrollermediaurl. How can i get the file path of selceted video file? Please guide me
iOS 8 open image picker very slow
my Xcode version is 4.6.3, Can i use QBImagePickerController?? please help me! thank you very much, there is no xcTestFramewrok in my Xcode, if i run my project in Xcode 5.0 ,if will report error like this ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Hi,
Been using your controller and works great in ios 7. In ios 8 same code the image picker always crashes before loading the photo albums:
2014-08-07 18:53:00.082 MYAPP[817:434075] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x2be89e2f 0x38f2ac8b 0x2bd9ee8d 0x54d3b 0x2f500251 0x2eede795 0x2eec81f3 0x2efaaf69 0x2eec79d1 0x2eec7681 0x2eeabb51 0x2eeab815 0x2eeab1f1 0x2eeaaff5 0x2eea4ecd 0x2be505bd 0x2be4dc7b 0x2be4e083 0x2bd9c611 0x2bd9c423 0x332f60a9 0x2f4e6485 0x2ea6d 0x394b0aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
Appears to be QBImagePickerThumbnailView crashing around this point:
UIImage *thumbnailImage = [self.thumbnailImages objectAtIndex:0];
CGRect thumbnailImageRect = CGRectMake(0, 4.0, 70.0, 70.0);
CGContextFillRect(context, thumbnailImageRect);
[thumbnailImage drawInRect:CGRectInset(thumbnailImageRect, 0.5, 0.5)];
The last issue posted mentions due to the Recently Deleted album introduced in ios 8, but I tried after emptying this album and it still crashes. Any ideas? Thanks!
ra
I am pushing it to a iPad Popover and setting the width to 800. But once I select the album it changes the width of the view to be much smaller. Is there a way to keep it at 800? I can't find the location in the code to get it to work.
Thanks for the great ImagePicker though, very extensible.
crash open big file size image.
file size of data checked the 25MB.
crash point,
QBImagePickerController.m
-(NSDictionary *)mediaInfoFromAsset:(ALAsset *)asset
[mediaInfo setObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]] forKey:@"UIImagePickerControllerOriginalImage"];
I am using Xcode6 ios swift and the simulator device is iphone 6 plus. I found that QBImagePickerController can only show "Recently Added" photos when selecting the images. The other albums were missing.
Info: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete and reload the same index path (<NSIndexPath: 0x18a62f00> {length = 2, path = 0 - 94})'
Exception Type: SIGABRT
Hardware Model: iPad3,4
OS Version: iPhone OS 8.4 (12H143)
Exception Type: SIGABRT
Exception Codes: #0 at 0x316addf0
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete and reload the same index path (<NSIndexPath: 0x18a62f00> {length = 2, path = 0 - 94})'
Last Exception Backtrace:
0 CoreFoundation 0x22973fef exceptionPreprocess + 127
1 libobjc.A.dylib 0x31031c8b objc_exception_throw + 36
2 CoreFoundation 0x22973ec5 +[NSException raise:format:arguments:] + 102
3 Foundation 0x23673f17 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 88
4 UIKit 0x265f0711 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:] + 1342
5 UIKit 0x265f492f -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 404
6 UIKit 0x265f4793 -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 28
7 UIKit 0x261b1617 -[UICollectionView performBatchUpdates:completion:] + 28
8 Foap 0x002b6b01 __48-[QBAssetsViewController photoLibraryDidChange:]_block_invoke (QBAssetsViewController.m:403)
9 libdispatch.dylib 0x315c22e3 _dispatch_call_block_and_release + 8
10 libdispatch.dylib 0x315c22cf _dispatch_client_callout + 20
11 libdispatch.dylib 0x315c5d2f _dispatch_main_queue_callback_4CF + 1328
12 CoreFoundation 0x22939609 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 6
13 CoreFoundation 0x22937d09 __CFRunLoopRun + 1510
14 CoreFoundation 0x22884201 CFRunLoopRunSpecific + 474
15 CoreFoundation 0x22884013 CFRunLoopRunInMode + 104
16 GraphicsServices 0x2a243201 GSEventRunModal + 134
17 UIKit 0x26050a09 UIApplicationMain + 1438
18 Foap 0x0003b2ab main (main.m:15)
19 libdyld.dylib 0x315e3aaf start + 0
I tried including every type from the Apple Documentation, ... except the video and hidden types:
[imagePickerController setAssetCollectionSubtypes:@[
@(PHAssetCollectionTypeAlbum),
@(PHAssetCollectionTypeSmartAlbum),
@(PHAssetCollectionTypeMoment),
@(PHAssetCollectionSubtypeAlbumRegular),
@(PHAssetCollectionSubtypeAlbumSyncedEvent),
@(PHAssetCollectionSubtypeAlbumSyncedFaces),
@(PHAssetCollectionSubtypeAlbumSyncedAlbum),
@(PHAssetCollectionSubtypeAlbumImported),
@(PHAssetCollectionSubtypeAlbumCloudShared),
@(PHAssetCollectionSubtypeSmartAlbumGeneric),
@(PHAssetCollectionSubtypeSmartAlbumPanoramas),
// @(PHAssetCollectionSubtypeSmartAlbumVideos),
@(PHAssetCollectionSubtypeSmartAlbumFavorites),
@(PHAssetCollectionSubtypeSmartAlbumTimelapses),
// @(PHAssetCollectionSubtypeSmartAlbumAllHidden),
@(PHAssetCollectionSubtypeSmartAlbumRecentlyAdded),
@(PHAssetCollectionSubtypeSmartAlbumBursts),
// @(PHAssetCollectionSubtypeSmartAlbumSlomoVideos),
@(PHAssetCollectionSubtypeAny)
] ];
Still, no matter what I've tried, it won't show all of the standard stuff from UIImagePickerController or that is synced from iPhoto. Basically all of my photos aren't there. Is this a behavior of the "PH" stuff, or am I missing something here?
Hi questbeat i am a new guy for developing ios,
Is there any example to get image back in delegate method with new API?
#pragma mark QBImagePickerControllerDelegate
- (void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didFinishPickingAssets:(NSArray *)assets{
for (PHAsset *asset in assets) {
PHAsset *asset = // how can i get back image???
.....
_myImageView.image=highQualityImage;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
Hi,
Is it possible to update the deployment target to 6.0 instead of 6.1 ? Pods complains about it unless I specify the target to be 6.1 in my podfile.
[!] The platform of the target 'Pods' (iOS 6.0) is not compatible with
'QBImagePickerController (2.1)' which has a minimum requirement of iOS 6.1.
Selecting images from Photo Stream on iOS 8.1 crashes because assetForURL:resultBlock:failureBlock: always returns a nil asset in that case.
Same as here: http://stackoverflow.com/questions/26480526/alassetslibrary-assetforurl-always-returning-nil-for-photos-in-my-photo-stream
error in self.fetchResults = @[smartAlbums, userAlbums];
but in IOS Simulator not error.
can u help me?thanks
Can you advise how to fix this?
Environment is IOS 9, xCode 7b3
Thanks
I need to localize the language into simplified Chinese. And I did the following:
I cannot figure it out why it will crash. please help or give me some hints. Thanks!!
I've compiled the framework with default settings, imported it into my project (default iOS architecture). I do have two different Bridging-Header files for the App and its WatchKit Extension. I #import the framework in the App target only.
I got an Apple Mach-O Linker Warning:
missing required architecture x86_64 in file
... /Frameworks/QBImagePicker.framework/QBImagePicker (2 slices)
Undefined symbols for architecture x86_64:
"OBJC_CLASS$_QBImagePickerController", referenced from:
__TMaCSo23QBImagePickerController in GCFoto.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?
In iOS 8, Pressing the Cancel button does not dismiss the Controller. How can we fix this?
Hi.
In QBImagePickerController class where you init controller you use
self.groupTypes = @[
@(ALAssetsGroupSavedPhotos),
@(ALAssetsGroupPhotoStream),
@(ALAssetsGroupAlbum)
];
The "ALAssetsGroupPhotoStream" value causes crash because it was deprecated (iOS 5.0)
Launching demo, when select an album the app crash with this error:
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithFormat:locale:arguments:]: nil argument'
*** First throw call stack:
the line that cause error is:
footerView.textLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTableInBundle(format,
@"QBImagePickerController",
[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"QBImagePickerController" ofType:@"bundle"]],
nil),
The returned bundle is always nil
Hi, Thanks a lot for your code.
I have a little suggest.
imagePickerController.allowsMultipleSelection = YES;
imagePickerController.minimumNumberOfSelection = 1;
imagePickerController.maximumNumberOfSelection = 1;
In this kind of case, when selecting a new picture can you make it deselect the old one automatically?
Then the user can select the new one without deselecting the old one before.
Because before tap the done button, user maybe change mind when scrolling.
I can't seem to figure out how to call it in swift?
For example, removed some of selected PHAssets in my .collectionView in delegate, I want to see all that PHAssets unselected in QBImagePicker ? How to do this?
Hello, first of all great work!
I was wondering if you can enforce a delegate that asks if a user is allowed to select a particular photo. The use case is that I have a camera within my app that I consume the image directly from and I also have, through you library, a way for the user to select photos. However, I want to prevent him selecting the same photos twice (the one taken through the camera from within my app, and from the camera roll). A simple method called shouldSelectPhoto and didSelectPhoto will open up interesting use cases to developers. Do let me know if this is possible, I don't mind contributing to it either.
Thanks a lot and great work once again!
so my solution way :
in QBAssetsCollectionViewController viewWillAppear: method
add
if (_imagePickerController.clearsSelectionOnViewWillAppear) {
// DLog(@"%@",self.collectionView.indexPathsForSelectedItems);
for (NSIndexPath *path in self.collectionView.indexPathsForSelectedItems) {
[self.collectionView deselectItemAtIndexPath:path animated:NO];
[self DeSelectImageWithIndexPath:path];
}
}
the [self DeSelectImageWithIndexPath:path]; method is
end.
(void)DeSelectImageWithIndexPath:(NSIndexPath *)indexPath{
ALAsset *asset = [self.assets objectAtIndex:indexPath.row];
// Validation
if (self.allowsMultipleSelection) {
self.navigationItem.rightBarButtonItem.enabled = [self validateNumberOfSelections:(self.imagePickerController.selectedAssetURLs.count - 1)];
}
// Delegate
if (self.delegate && [self.delegate respondsToSelector:@selector(assetsCollectionViewController:didDeselectAsset:)]) {
[self.delegate assetsCollectionViewController:self didDeselectAsset:asset];
}
}
Hi
To reproduce the crash:
1 - Add some photos (or videos)
2 - Open QBImagePicketController
3 - Select 'My Photo Stream'
4 - Select a photo
5 - Click on 'Done'
It will crash at line 263 on QBImagePickerController.m
method passSelectedAssetsToDelegate
.
At line 263 asset
variable is nil
.
My config:
Xcode Version 6.1 (6A1052d)
iPhone 6+ on iOS 8.1 (12B411)
If QBImagePickerController use a delegate that did not implement "descriptionForSelectingAllAssets:" / "descriptionForDeselectingAllAssets:", when I try to select all assets from the photo library, the QBAssetCollectionViewController will crash.
I've installed v2.5.1 through CocoaPods, since my app needs to support iOS 7. Now, whenever I display the picker, the title is always アルバム. My project is all-English and does not have any kind of i18n code in it.
I did have a Japanese keyboard added in Settings, which I removed, and the issue continues. It also happens on the simulator.
How can I force QBImagePickerController
to display only in English?
よろしくお願いします。😀
Hello questbeat, I don't find anything diff between PhotoKit and AssetLibrary, Why to use PhotoKit on iOS8 instead of AssetLibrary, what do you think?
I'm getting this NSRangeException (and the app locks up) when I use the QBImagePicker and select my Camera Roll.
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 28 beyond bounds [0 .. 27]'
When I select Camera Roll in my QBImagePicker, this exception is raised and the app stops responding.
They symptoms & cause of the issue are below:
Once again, Apple have gone and stuffed it - those Deleted Photos really shouldn't be counted in a normal API call to get the Photo Album, but hey... here we are, and it'll need a bit of a workaround maybe.
Thanks (great controller by the way).
I use a collectionView to show what the asset user selected. when user tap the cell in collectionView, i want to unselected a asset in QBImagePicker. At now, i open QBImagePicker, previous selected asset is always selected if you never touch it in QBImagePicker.
Hello. First of all, let me tell you , nice component, I really like it.
Second.. I have a situation here, I'm pretty sure is an easy fix. When the picker pushes some album for first time, the collection is scrolled to the bottom, which is great, but once I select an image, the toolbar with the number of selected assets covers half of the last row. See Image. So user has to scroll it manually to see again the full thumbnails.
Hi, I'm trying to use your wonderfull library, when I used it on a new test project it worked like a charm. the problem is when I try copiying to my official project xhere I need it, it displays the albums correctly, but whenever I select an album, it don't show the thumbs unless I scroll manually the tableView ! May be I'm doing some wrong steps, So here is the code :
QBImagePickerController *imagePickerController = [[QBImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.allowsMultipleSelection = YES;
imagePickerController.limitsMaximumNumberOfSelection = YES;
imagePickerController.maximumNumberOfSelection = 6;
imagePickerController.fullScreenLayoutEnabled=NO;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:imagePickerController];
[self presentViewController:navigationController animated:YES completion:NULL];
Please Any idea? I'm so stressed to finish my project? Thanks.
Hi
First of all, thanks for the wonderful artifact.
I observed on issue on iOS8.3 SDK, Probably previous version of SDK.
If there is no asset in folder(Album), line 373 in QBAssetsViewController.m throws an exception.
It tries to access an item that does not exist. PHFetchResult contains nothing.
how can i got the uiimage from the func didFinishPickingAssets help!!!
Whenever I try to run the picker on the simulator, I get apple Mach-O-Link error. This is the warning:
ignoring file /Users/roeik/Library/Developer/Xcode/DerivedData/QBImagePicker-echovqawkwxhtfbqzjlyhyemcfra/Build/Products/Debug-iphoneos/QBImagePicker.framework/QBImagePicker, file was built for arm64 which is not the architecture being linked (x86_64): /Users/roeik/Library/Developer/Xcode/DerivedData/QBImagePicker-echovqawkwxhtfbqzjlyhyemcfra/Build/Products/Debug-iphoneos/QBImagePicker.framework/QBImagePicker
Also, when I run on the device the project built ok but the thumbnails in the picker are low res and blurry. What to do?
I just built the framework in the demo proect and dragged it. Please help.
select photos and click done button, but the delegate not call, the done action also not call
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.