美文网首页iOS 奇闻轶事
iOS开发记录 QBImagePickerController调

iOS开发记录 QBImagePickerController调

作者: Jacky__燊 | 来源:发表于2019-03-21 15:35 被阅读0次

在调用弹出QBImagePickerController之后发现顶部上移了一部分。问题如下:


图片.png

寻思着肯定是适配的问题。
记得已经在AppDelegate里面设置了全局了的UIScrollViewContentInsetAdjustmentNever。

问题确实是再这里,解决方案如下:

第一:在弹出系统相册的函数里按顺序添加

//先写这个
if (@available(iOS 11, *)) { 
  UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic; 
} 

QBImagePickerController *qbpicker = [[QBImagePickerController alloc] init]; qbpicker.delegate = self; 

// 再写这个
if (@available(iOS 11, *)) { 
  UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic; 
} 
[self presentViewController:qbpicker animated:YES completion:nil];

第二:然后在代理方法里添加

-(void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didFinishPickingAssets:(NSArray *)assets{
   
//再设置为never
    if (@available(iOS 11, *)) {
        UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    [self dismissViewControllerAnimated:YES completion:NULL];
}

正常效果:


图片.png

相关文章

网友评论

    本文标题:iOS开发记录 QBImagePickerController调

    本文链接:https://www.haomeiwen.com/subject/wctcvqtx.html