问题示例:
在AppDelegate.m设置了
if (@available(iOS 11.0, *)) {
[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
打开相册后界面整体往上偏移。两种办法:
方法一:(参考:iOS 11打开系统相册列表向上偏移问题 并稍作补充)
在打开相册前设置
if (@available(iOS 11, *)) {
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
}
在
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
和
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
方法中设置
if (@available(iOS 11, *)) {
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
方法二:将导航条的毛玻璃效果去除(参考:UIImagePickerController iOS11调起相册 中的照片被导航栏遮挡)
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
controller.delegate = self;
controller.navigationBar.translucent = NO; //去除毛玻璃效果
[self presentViewController:controller animated:YES completion:nil];