调用系统UIImagePickerController相册时候出现UIImagePickerController Frame不对的问题如图所示。
没有适配IOS11效果[图片上传中)]我们怎么解决Frame不对导致系统UIImagePickerController被导航栏遮挡的问题呢?
第一步
我们需要在进入到UIImagePickerController
/*适配ios11 导航栏*/
UIImagePickerController *pc = [[UIImagePickerController alloc]init];
pc.delegate = self;
[pc setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[pc setModalPresentationStyle:UIModalPresentationFullScreen];
[pc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
/*适配ios11 导航栏*/
if (@available(iOS 11, *)) {
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
}
[pc setAllowsEditing:YES];
[self presentViewController:pc animated:YES completion:nil];
第二步我们需要在退出UIImagePickerController时候填写
/*UIImagePickerController 解决导航栏问题*/
if (@available(iOS 11, *)) {
[UIScrollView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; //iOS11 解决SafeArea的问题,同时能解决pop时上级页面scrollView抖动的问题
}
你会发现效果发生了改变 如图~
适配IOS11效果
希望能帮到您~
网友评论