iOS: Use the built-in picture manager to crop the picture, the solution to the problem that the picture will move down 20pt after iOS 11

I won't talk about the tailoring part, there are many online,

The problem is this, after calling the system's crop, the cropped image is not the previously selected area, it will be moved down by 20 pt values, this is a bug after iOS 11, I have seen netizens share a hidden status bar , it can be solved, but the timing of this hiding is confusing at first, and it is OK to hide it when the UIImagePickerController appears, but it is not elegant, (the method of hiding the state, there is a portal )

Here I share a solution I found out by myself,

The idea at the beginning was to find the image click method in PickerVC, hide it when it jumps to the crop page, and display it when it returns. Unfortunately, Apple doesn't seem to provide an api for clicking, and it's really unnecessary to think about it....

But I think this direction is right, although it is a bit frustrated,

When looking at the API I noticed that ImagePickerVC follows two delegates UIImagePickerControllerDelegate and UINaviigationControllerDelegate

There is this proxy method in navDelegate


- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {

    if ([navigationController.viewControllers count] == 3) {

        [[UIApplication sharedApplication] setStatusBarHidden:YES];

    }else {

        [[UIApplication sharedApplication] setStatusBarHidden:NO];

    }



}


In it to determine whether to jump to the clipping page, it is OK to hide and display the status bar in a timely manner. Since I printed the class name of the VC, they are all PUUIImageViewController, so I use the method of judging the number to do it, if you have Better solutions, welcome to share~




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324835725&siteId=291194637