問題示例:
在AppDelegate.m設(shè)置了
if (@available(iOS 11.0, *)) {
? ? ? ? [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
打開相冊后界面整體往上偏移挟纱。兩種辦法:
方法一:(參考:iOS 11打開系統(tǒng)相冊列表向上偏移問題?并稍作補充)
在打開相冊前設(shè)置
if (@available(iOS 11, *)) {
? ? ? ? UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
}
在
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
和
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
方法中設(shè)置
if (@available(iOS 11, *)) {
? ? ? ? UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
方法二:將導(dǎo)航條的毛玻璃效果去除(參考:UIImagePickerController iOS11調(diào)起相冊 中的照片被導(dǎo)航欄遮擋)
? ? ? ? UIImagePickerController *controller = [[UIImagePickerController alloc] init];
? ? ? ? controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
? ? ? ? controller.delegate = self;
? ? ? ? controller.navigationBar.translucent = NO; //去除毛玻璃效果
? ? ? ? [self presentViewController:controller animated:YES completion:nil];