问题描述
在 iOS 11 下,如果给 UIImagePickerController 设置 allowsEditing = YES,然后在编辑图片的时候,却发现左下角的那个 取消 按键怎么也没法点击到
问题原理
在打开编辑模式的时候,实际上是一个 PUPhotoPickerHostViewController, 搞不懂为什么左边会出现一条大概 41 像素的空白视图。
如图

解决办法
- (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;
}
}];
}
}
处理后

网友评论