UIImagePickerController 编辑图片时的左下
2018-08-17 本文已影响606人
yaoyao_IOS
在 iOS 11 下,如果给 UIImagePickerController 设置 allowsEditing = YES,然后在编辑图片的时候,却发现左下角的那个 取消 按键怎么也没法点击到
解决方法:
只需在使用 UIImagePickerController 的delegate方法中添加一下代码即可
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if ([UIDevice currentDevice].systemVersion.floatValue < 11) {
return;
}
if ([viewController isKindOfClass:NSClassFromString(@"PUPhotoPickerHostViewController")]) {
[viewController.view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.frame.size.width < 42) {
[viewController.view sendSubviewToBack:obj];
*stop = YES;
}
}];
}
}