Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

2.1 iOS Usage Instructions

Ruben Nine edited this page Aug 14, 2015 · 1 revision

Importing

@import FPPicker;

Opening Files

// To create the object

FPPickerController *pickerController = [FPPickerController new];

// Set the delegate

pickerController.fpdelegate = self;

// Ask for specific data types. (Optional) Default is all files

pickerController.dataTypes = @[
    @"text/plain"
];

// Select and order the sources (Optional) Default is all sources

pickerController.sourceNames = @[
    FPSourceImagesearch,
    FPSourceDropbox
];

// You can set some of the in built Camera properties as you would with UIImagePicker

pickerController.allowsEditing = YES;

// Allowing multiple file selection

pickerController.selectMultiple = YES;

// Limiting the maximum number of files that can be uploaded at one time

pickerController.maxFiles = 5;


/* Control if we should upload or download the files for you.
 * Default is YES.
 * When a user selects a local file, we'll upload it and return a remote URL.
 * When a user selects a remote file, we'll download it and return the filedata to you.
 */

pickerController.shouldUpload = YES;
pickerController.shouldDownload = YES;

// Display it

[self presentViewController:fpController
                   animated:YES
                 completion:nil];

Saving Files

// To create the object

FPSaveController *saveController = [FPSaveController new];

// Set the delegate

saveController.fpdelegate = self;

// Ask for specific data mimetypes. (Optional) Default is all files

fpController.dataTypes = @[@"text/plain"];

// Select and order the sources (Optional) Default is all sources

saveController.sourceNames = @[
    FPSourceCamera,
    FPSourceCameraRoll,
    FPSourceDropbox,
    FPSourceFacebook,
    FPSourceGmail,
    FPSourceBox,
    FPSourceGithub,
    FPSourceGoogleDrive,
    FPSourceImagesearch
];

// Set the data and data type to be saved

saveController.data = [NSData new];
saveController.dataType = @"text/plain";
//alternative: saveController.dataExtension = @"txt"

// (Optional) Propose the default file name

saveController.proposedFilename = @"AwesomeFile";

// Display it

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    self.popoverController = [[UIPopoverController alloc] initWithContentViewController:saveController];

    // You can set the delegate of the popover to be the FPPicker if you want FPPicker to report
    // when the popover has been dismissed as a cancel

    self.popoverController.delegate = saveController;

    self.popoverController.popoverContentSize = CGSizeMake(320, 520);

    [self.popoverController presentPopoverFromRect:[sender frame]
                                            inView:self.view
                          permittedArrowDirections:UIPopoverArrowDirectionAny
                                          animated:YES];
}
else
{
    [self presentViewController:saveController
                       animated:YES
                    completion:nil];
}

More Information