iosuidocumentinteraction

UIDocumentInteractionController works but doesn't show "Save Image"


I create and present a UIDocumentInteractionController with a valid url to a saved image but when I present the controller "Save Image" does not appear.

NSURL *url = ...;
self.interactionController = [UIDocumentInteractionController interactionControllerWithURL:url];
[self.interactionController presentOptionsMenuFromBarButtonItem:sender animated:YES];

I have verified self.interactionController.UTI is a valid image type (jpeg)

______Actual_______ vs.____Expected_____

Actual image____ Expected image

Note* If anyone knows a better way to format those images please be my guest


Solution

  • In order to have the option to save to the camera roll, the app must have permission to access photos.

    Relative to ALAuthorizationStatus ([ALAssetsLibrary authorizationStatus])

    "Save Image" is displayed for

    1. ALAuthorizationStatusAuthorized
    2. ALAuthorizationStatusNotDetermined

    "Save Image" is not displayed for

    1. ALAuthorizationStatusRestricted
    2. ALAuthorizationStatusDenied

    You can do a check like this:

    #import <AssetsLibrary/AssetsLibrary.h>
    
    - (BOOL)canSaveToCameraRoll
    {
        ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
        return (status == ALAuthorizationStatusAuthorized || status == ALAuthorizationStatusNotDetermined);
    }