iOS 11 調(diào)用系統(tǒng)相冊(cè)界面往上偏移問(wèn)題

問(wèn)題示例:

示例圖片

在AppDelegate.m設(shè)置了

if (@available(iOS 11.0, *)) {

? ? ? ? [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];

}

打開相冊(cè)后界面整體往上偏移。兩種辦法:

方法一:(參考:iOS 11打開系統(tǒng)相冊(cè)列表向上偏移問(wèn)題?并稍作補(bǔ)充)

在打開相冊(cè)前設(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)起相冊(cè) 中的照片被導(dǎo)航欄遮擋

? ? ? ? UIImagePickerController *controller = [[UIImagePickerController alloc] init];

? ? ? ? controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

? ? ? ? controller.delegate = self;

? ? ? ? controller.navigationBar.translucent = NO; //去除毛玻璃效果

? ? ? ? [self presentViewController:controller animated:YES completion:nil];

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容