Search code examples
iosaviary

Aviary crop presets not working on iOS


I'm trying to force users to crop their photo to a square with Aviary. As described in the Aviary documentation here, it is possible to disable custom crops and specify the presets manually. I am attempting the following:

[AFPhotoEditorCustomization setCropToolOriginalEnabled:NO];
[AFPhotoEditorCustomization setCropToolCustomEnabled:NO];
NSDictionary *SIZE = [[NSDictionary alloc] initWithObjectsAndKeys:
                      @"kAFCropPresetName",@"square",
                      @"kAFCropPresetWidth",@"1.0f",
                      @"kAFCropPresetHeight",@"1.0f",
                      nil];
[AFPhotoEditorCustomization setCropToolPresets:[[NSArray alloc] initWithObjects:SIZE, nil]];

But this does not work. This results is 0 cropping options:


Solution

  • You should use the below code:

    [AFPhotoEditorCustomization setCropToolOriginalEnabled:NO]; [AFPhotoEditorCustomization setCropToolCustomEnabled:NO]; NSDictionary * square = @{kAFCropPresetName: @"Square", kAFCropPresetHeight : @(1.0f), kAFCropPresetWidth : @(1.0f)}; [AFPhotoEditorCustomization setCropToolPresets:@[square]];