ImagePicker.launchCameraAsync displays the Camera under Modal on iOS 14.5
See original GitHub issueSummary
Problem: The Camera is displayed under Modal after upgrading to iOS 14.5
Expected behavior: Display Camera over Modal
Source Code
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { Button, StyleSheet, Text, View, Modal } from 'react-native';
import * as ImagePicker from 'expo-image-picker';
export default function App() {
return (
<View style={styles.container}>
<StatusBar style="auto" />
<Modal
visible={true}
animationType="slide"
hardwareAccelerated={true}
transparent={true}
>
<View style={styles.modal}>
<View style={{ width: 200, height: 200, backgroundColor: "#fff" }}>
<Button title="Camera" onPress={async () => {
const { status: cameraStatus } = await ImagePicker.requestCameraPermissionsAsync()
.catch(err => console.log(`camera_permission_err: ${err}`));
const { status: cameraRollStatus } = await ImagePicker.requestMediaLibraryPermissionsAsync()
.catch(err => console.log(`camera_roll_permission_err: ${err}`));
if (cameraStatus !== 'granted' || cameraRollStatus !== 'granted') {
Alert.alert(
'Permission not granted',
'Please allow this app to access camera and photo library in your phone\'s setting.',
[
{
text: 'OK',
onPress: async () => {
if (cameraStatus !== 'granted') {
await ImagePicker.requestCameraPermissionsAsync();
}
if (cameraRollStatus !== 'granted') {
await ImagePicker.requestMediaLibraryPermissionsAsync();
}
},
},
],
{ cancelable: true },
);
return;
}
const capturedImage = await ImagePicker.launchCameraAsync({
allowsEditing: false,
aspect: [4, 3],
base64: true,
}).catch(err => {
console.log(err)
});
console.log(capturedImage)
}} />
</View>
</View>
</Modal>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
modal: {
flex: 1,
backgroundColor: '#fff0',
alignItems: 'center',
justifyContent: 'center',
},
});
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
iOS
SDK Version (managed workflow only)
41
Environment
Expo CLI 4.4.3 environment info: System: OS: Windows 10 10.0.18363 Binaries: Node: 10.16.3 - C:\Program Files\nodejs\node.EXE Yarn: 1.19.1 - C:\Users\xidanzheng\AppData\Roaming\npm\yarn.CMD npm: 6.14.8 - C:\Users\xidanzheng\AppData\Roaming\npm\npm.CMD npmPackages: expo: ~41.0.1 => 41.0.1 react: 16.13.1 => 16.13.1 react-dom: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz => 0.63.2 react-native-web: ~0.13.12 => 0.13.18 Expo Workflow: managed
Reproducible demo or steps to reproduce from a blank project
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:27 (5 by maintainers)
Top Results From Across the Web
ImagePicker with Modal stops working after iOS 14.5.0 update
1. The problem is related to Expo's Modal component, because I have one open (full screen) which is giving the user the buttons...
Read more >Expo ImagePicker crashed on IOS Gallery not opening
try adding this to your object, like so, ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.
Read more >Example of Image Picker in React Native
For picking the image we will use a very good library called react-native-image-picker . It is a React Native module that allows you...
Read more >Native camera rendering broken after upgrade to Expo 42 ...
Coding example for the question Native camera rendering broken after upgrade to ... Import statements... import * as ImagePicker from 'expo-image-picker'; ...
Read more >How to use the expo-image-picker.launchCameraAsync ...
Provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera. GitHub....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Currently looking into a fix, at first glance this seems due to the
modalPresentationStyle
we are setting.This issue is now a problem on IOS 14.5 official version, this is causing a lot of issues. 😦