1. 程式人生 > >iOS11 開啟相簿上移問題解決方法

iOS11 開啟相簿上移問題解決方法

原因是app設定了:

if (@available(iOS 11, *)) {
    UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
 }

解決方案 :
在彈出系統相簿前新增

 if (@available(iOS 11, *)) {
 UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
    }
 UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
 ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
 ipc.delegate = self;
 ipc.allowsEditing = YES;
 if (@available(iOS 11, *)) {
        UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
    }
 [self presentViewController:ipc animated:YES completion:nil];

在 - (void)imagePickerController:(UIImagePickerController )picker didFinishPickingMediaWithInfo:(NSDictionary*)dic新增

if (@available(iOS 11, *)) {
        UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }