iOS 11 调用系统相册界面往上偏移问题

问题示例:

iOS 11 调用系统相册界面往上偏移问题_第1张图片
示例图片

在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 *)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];

你可能感兴趣的:(iOS 11 调用系统相册界面往上偏移问题)