Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/alondon/AssetPicker into al…
Browse files Browse the repository at this point in the history
…ondon-master

Conflicts:
	DIYAssetPicker/DIYAssetPickerController.m
  • Loading branch information
dongle committed Mar 22, 2013
2 parents 7867a82 + fe4902c commit 1fdf683
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions DIYAssetPicker/DIYAssetPickerController.h
Expand Up @@ -50,5 +50,6 @@ NSString *const DIYAssetPickerThumbnail;


#pragma mark - Options #pragma mark - Options
@property (nonatomic, assign) DIYAssetPickerControllerAssetType assetType; @property (nonatomic, assign) DIYAssetPickerControllerAssetType assetType;
@property (nonatomic, assign) ALAssetsGroupType groupType;


@end @end
16 changes: 12 additions & 4 deletions DIYAssetPicker/DIYAssetPickerController.m
Expand Up @@ -31,6 +31,7 @@ - (id)init
{ {
if (self = [super init]) { if (self = [super init]) {
_assetType = DIYAssetPickerPhotoVideo; _assetType = DIYAssetPickerPhotoVideo;
_groupType = ALAssetsGroupSavedPhotos;
} }


return self; return self;
Expand Down Expand Up @@ -258,14 +259,21 @@ - (void)setAssetType:(DIYAssetPickerControllerAssetType)assetType
[self.assetsTable reloadData]; [self.assetsTable reloadData];
} }


- (void)setGroupType:(ALAssetsGroupType)groupType
{
self->_groupType = groupType;
[self getAssetsArray];
[self.assetsTable reloadData];
}

#pragma mark - Utility #pragma mark - Utility


- (void)getAssetsArray - (void)getAssetsArray
{ {
[self.assetsArray removeAllObjects]; [self.assetsArray removeAllObjects];


[self.assetsLibrary [self.assetsLibrary
enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos enumerateGroupsWithTypes:self.groupType
usingBlock:^(ALAssetsGroup *group, BOOL *stop) { usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (self.assetType == DIYAssetPickerPhoto) { if (self.assetType == DIYAssetPickerPhoto) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]]; [group setAssetsFilter:[ALAssetsFilter allPhotos]];
Expand All @@ -292,10 +300,10 @@ - (void)getAssetsArray
NSInteger code = [error code]; NSInteger code = [error code];
if (code == ALAssetsLibraryAccessUserDeniedError || code == ALAssetsLibraryAccessGloballyDeniedError) { if (code == ALAssetsLibraryAccessUserDeniedError || code == ALAssetsLibraryAccessGloballyDeniedError) {
UIAlertView *alert = [[UIAlertView alloc] UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error" initWithTitle:NSLocalizedString(@"Privacy Error", @"Privacy error title.")
message:@"Can't access photos - please allow access via the settings app. On iOS 5, enable 'location data' for this app. On iOS 6, go to privacy and enable photo access for this app." message:NSLocalizedString(@"Please go to the Settings app > Privacy > Photos and enable access for this app in order to choose photos from the device library.", @"Privacy error message.")
delegate:nil delegate:nil
cancelButtonTitle:@"OK" cancelButtonTitle:NSLocalizedString(@"OK", @"OK button title.")
otherButtonTitles:nil]; otherButtonTitles:nil];
[alert show]; [alert show];
} }
Expand Down

0 comments on commit 1fdf683

Please sign in to comment.