简体   繁体   中英

IMGLYMainEditorViewController completion block issue

I successfully implemented imglyKit in my Objective-C code, this library is made in swift language. Now i am opening a IMGLYMainEditorViewController from my viewcontroller. My problem is that when the image is edited and when i press the done button i did not get the edited image. I checked the code and show that they set the completion block when they open IMGLYMainEditorViewController.

This is the code which is written in the library.

let editorViewController = IMGLYMainEditorViewController()
        editorViewController.highResolutionImage = image
        if let cameraController = cameraController {
            editorViewController.initialFilterType = cameraController.effectFilter.filterType
            editorViewController.initialFilterIntensity = cameraController.effectFilter.inputIntensity
        }
        editorViewController.completionBlock = editorCompletionBlock

private func editorCompletionBlock(result: IMGLYEditorResult, image: UIImage?) {
        if let image = image where result == .Done {
            UIImageWriteToSavedPhotosAlbum(image, self, "image:didFinishSavingWithError:contextInfo:", nil)
        }

        dismissViewControllerAnimated(true, completion: nil)
    }

I wrote this code in my controller.

    IMGLYMainEditorViewController *temp view = [[IMGLYMainEditorViewController alloc]init];
    view.highResolutionImage = self.image_view.image;
    [self.navigationController pushViewController:view animated:YES];

I want to set a block method here when i open a IMGLYMainEditorViewControlle so that i am able to get that edited image.

I did lots of try but not able to do that because i did not have a much knowledge about the block and how to deal with that. so please help me because i stuck here.

  1. Remove the space between "temp view" instance name,
  2. This is how you provide a completion block to an object:

    IMGLYMainEditorViewController *tempView = [[IMGLYMainEditorViewController alloc] init]; tempView.completionBlock = ^(IMGLYEditorResult result, UIImage *image){ view.highResolutionImage = image; }; [self.navigationController pushViewController:view animated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM