yackle / CLImageEditor

MIT License
2.21k stars 574 forks source link

iOS11 -- When pushed onto a UINavigationController stack Done button is missing #193

Closed kezzico closed 6 years ago

kezzico commented 6 years ago

Here is the code to reproduce:

UIViewController *rootVc = ... ;
CLImageEditor *editor = [[CLImageEditor alloc] initWithImage:image];

[[UINavigationController alloc] initWithRootViewController:rootVc];

[self.navigationController setNavigationBarHidden:YES animated:NO];

[rootVc pushViewController: editor animated:YES];

CLImage Editor will unhide the navigation bar. However, the "Done" button will be missing. I tracked the issue down to line 97 in _CLImageEditorViewController. It looks like the way the navigation bar is being created causes a strange side effect.

I was able to bring the Done button back by commenting out 97 through 117 in _CLImageEditorViewController seen below.


    self.navigationItem.rightBarButtonItem = rightBarButtonItem;
    [self.navigationController setNavigationBarHidden:NO animated:NO];

    // if(_navigationBar==nil){
    //     UINavigationItem *navigationItem  = [[UINavigationItem alloc] init];
    //     navigationItem.leftBarButtonItem  = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(pushedCloseBtn:)];
    //     navigationItem.rightBarButtonItem = rightBarButtonItem;

    //     CGFloat dy = ([UIDevice iosVersion]<7) ? 0 : MIN([UIApplication sharedApplication].statusBarFrame.size.height, [UIApplication sharedApplication].statusBarFrame.size.width);

    //     UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, dy, self.view.width, kNavBarHeight)];
    //     [navigationBar pushNavigationItem:navigationItem animated:NO];
    //     navigationBar.delegate = self;

    //     if(self.navigationController){
    //         [self.navigationController.view addSubview:navigationBar];
    //         [_CLImageEditorViewController setConstraintsLeading:@0 trailing:@0 top:@(dy) bottom:nil height:@(kNavBarHeight) width:nil parent:self.navigationController.view child:navigationBar peer:nil];
    //     }
    //     else{
    //         [self.view addSubview:navigationBar];
    //         [_CLImageEditorViewController setConstraintsLeading:@0 trailing:@0 top:@(dy) bottom:nil height:@(kNavBarHeight) width:nil parent:self.view child:navigationBar peer:nil];
    //     }
    //     _navigationBar = navigationBar;
    // }

    if(self.navigationController!=nil){
yackle commented 6 years ago

Thanks for reporting, I'll look into this issue.