yackle / CLImageEditor

MIT License
2.21k stars 574 forks source link

Navigation bar dives into the status bar when pushed from UIImagePickerController #220

Open takep2 opened 5 years ago

takep2 commented 5 years ago

Steps to reproduce.

  1. Download CLImageEditor-0.2.4.zip
  2. Open Demo/CLIMageEditorDemo/CLImageEditorDemo.xcodeproj
  3. Run on iPhone X Simulator
  4. Tap 'New' button on Tabbar
  5. Select 'Photo Library' on ActionSheet
  6. Select photo on UIImagePickerController
  7. Select toolbar button (e.g. Filter button) on CLImagEditor screen

Then navigation bar dives into the status bar. So I can't tap Back button or OK button.

This occurs from 0.2.4. There is no problem with 0.2.3.

takep2 commented 5 years ago

I found the workaround for this issue.

CLImageEditor0.2.4 works fine with modal screen transition.

So, when we transit from UIImagePickerController to CLImageEditor, instead of a push transition using pushViewController, modal screen transition using presentViewController, all the subsequent operations will work well.

Specifically, in the ViewController.m file of CLImageEditorDemo project, change the code in the didFinishPickingMediaWithInfo method from pushViewController to presentViewController as follows.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

    CLImageEditor *editor = [[CLImageEditor alloc] initWithImage:image];
    editor.delegate = self;

//    [picker pushViewController:editor animated:YES];
    [picker presentViewController:editor animated:YES completion:nil];
}

Then, instead of closing CLImageEditor in the didFinishEditingWithImage method, close UIImagePickerController by specifying self as follows.

- (void)imageEditor:(CLImageEditor *)editor didFinishEditingWithImage:(UIImage *)image
{
    _imageView.image = image;
    [self refreshImageView];

//    [editor dismissViewControllerAnimated:YES completion:nil];
    [self dismissViewControllerAnimated:YES completion:nil];
}

In addition to that, adding the implementation of the imageEditorDidCancel method as follows can avoid the issue of #97.

- (void)imageEditorDidCancel:(CLImageEditor *)editor
{
    [self dismissViewControllerAnimated:YES completion:nil];
}