Skip to content
This repository was archived by the owner on Jul 16, 2019. It is now read-only.

Commit

Permalink
Allow the single selection message to be customised.
Browse files Browse the repository at this point in the history
Requested feature!
  • Loading branch information
krider2010 committed Dec 22, 2015
1 parent 4af84fe commit c1c1716
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Examples/GMPhotoPicker/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ - (IBAction)launchGMImagePicker:(id)sender
picker.colsInLandscape = 5;
picker.minimumInteritemSpacing = 2.0;

picker.allowsMultipleSelection = NO;
// picker.allowsMultipleSelection = NO;
// picker.confirmSingleSelection = YES;
// picker.confirmSingleSelectionPrompt = @"Do you want to select the image you have chosen?";

// picker.showCameraButton = YES;
// picker.autoSelectCameraImages = YES;
Expand Down
5 changes: 5 additions & 0 deletions GMImagePicker/GMImagePickerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ static CGSize const kPopoverContentSize = {480, 720};
*/
@property (nonatomic, assign) BOOL confirmSingleSelection;

/**
* If set, it displays this string (if confirmSingleSelection = YES) instead of the localised default.
*/
@property (nonatomic, assign) NSString *confirmSingleSelectionPrompt;

/**
* True to always show the toolbar, with a camera button allowing new photos to be taken. False to auto show/hide the
* toolbar, and have no camera button. Default is false. If true, this renders displaySelectionInfoToolbar a no-op.
Expand Down
12 changes: 9 additions & 3 deletions GMImagePicker/GMImagePickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ @implementation GMImagePickerController

- (id)init
{
if (self = [super init])
{
if (self = [super init]) {
_selectedAssets = [[NSMutableArray alloc] init];

// Default values:
Expand All @@ -29,6 +28,7 @@ - (id)init
_autoDisableDoneButton = YES;
_allowsMultipleSelection = YES;
_confirmSingleSelection = NO;
_confirmSingleSelectionPrompt = nil;
_showCameraButton = NO;

// Grid configuration:
Expand Down Expand Up @@ -148,9 +148,15 @@ - (void)selectAsset:(PHAsset *)asset

if (!self.allowsMultipleSelection) {
if (self.confirmSingleSelection) {
NSString *message;
if (self.confirmSingleSelectionPrompt != nil) {
message = self.confirmSingleSelectionPrompt;
} else {
message = [NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"picker.confirm.message", @"GMImagePicker", [NSBundle bundleForClass:GMImagePickerController.class], @"Do you want to select the image you tapped on?")];
}

[[[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"picker.confirm.title", @"GMImagePicker", [NSBundle bundleForClass:GMImagePickerController.class], @"Are You Sure?")]
message:[NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"picker.confirm.message", @"GMImagePicker", [NSBundle bundleForClass:GMImagePickerController.class], @"Do you want to select the image you tapped on?")]
message:message
delegate:self
cancelButtonTitle:[NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"picker.action.no", @"GMImagePicker", [NSBundle bundleForClass:GMImagePickerController.class], @"No")]
otherButtonTitles:[NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"picker.action.yes", @"GMImagePicker", [NSBundle bundleForClass:GMImagePickerController.class], @"Yes")], nil] show];
Expand Down

0 comments on commit c1c1716

Please sign in to comment.