yackle / CLImageEditor

MIT License
2.22k stars 574 forks source link

Unable to modify Back button action #120

Closed komaldaudia closed 8 years ago

komaldaudia commented 8 years ago

I want to popup alert before cancelling the image editing , but i am anable to track the method and also optional delegate method is not calling "imageEditorDidCancel", i have set the delegate too, Kindly revert ASAP.

thank you in advance

yackle commented 8 years ago

If the editor is used with UIImagePickerController, try

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if([navigationController isKindOfClass:[UIImagePickerController class]] && [viewController isKindOfClass:[CLImageEditor class]]){
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonDidPush:)];
    }
}

- (void)cancelButtonDidPush:(id)sender
{
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
komaldaudia commented 8 years ago

Thank you @yackle for the quick help, it worked. :)