QLPreviewController editing mode not working?

1.4k views Asked by At

Are you able to edit images with QLPreviewController?

For example, preview an image and crop it? If not, what is the editing property on QLPreviewController for? It doesn't seem to change anything. (Previewing files is working fine)

Here is an example:

QLPreviewController *previewController=[[QLPreviewController alloc]init];
previewController.delegate=self;
previewController.dataSource=self;
[previewController setCurrentPreviewItemIndex:selectedIndex];
[previewController setEditing:YES animated:YES];

[self presentModalViewController:previewController animated:YES];

Delegate methods:

- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
    file = [folder.files objectAtIndex:index];

    controller.title = file.name;

    CustomQLPreviewItem *customQLPreviewItem = [[CustomQLPreviewItem alloc] init];

    customQLPreviewItem.previewItemURL = [NSURL fileURLWithPath:file.uri];
    customQLPreviewItem.previewItemTitle = file.name;

    return customQLPreviewItem;
}

- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
    return folder.file.count;
}
1

There are 1 answers

1
valheru On BEST ANSWER

QLPreviewController does not support editing in the way you are thinking.

the editing property is actually inherited from UIViewController and from here:

UIViewController Class Reference

editing A Boolean value indicating whether the view controller currently allows the user to edit the view contents.

@property(nonatomic, getter=isEditing) BOOL editing Discussion If YES, the view controller currently allows editing; otherwise, NO.

If the view is editable and the associated navigation controller contains an edit-done button, then a Done button is displayed; otherwise, an Edit button is displayed. Clicking either button toggles the state of this property. Add an edit-done button by setting the custom left or right view of the navigation item to the value returned by the editButtonItem method. Set the editing property to the initial state of your view. Use the setEditing:animated: method as an action method to animate the transition of this state if the view is already displayed.

Availability Available in iOS 2.0 and later. See Also – setEditing:animated: – editButtonItem Related Sample Code BonjourWeb iPhoneCoreDataRecipes Declared In UIViewController.h