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

2018-12-17  本文已影响0人  Accepted_

问题示例:

示例图片

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

上一篇 下一篇

猜你喜欢

热点阅读