question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImagePicker.launchCameraAsync displays the Camera under Modal on iOS 14.5

See original GitHub issue

Summary

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

Demo https://snack.expo.io/@macroview.dbs/test

https://user-images.githubusercontent.com/34149063/116500022-36c5b780-a8e0-11eb-9ae6-09d49225e75a.mp4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:27 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
cruzachcommented, May 11, 2021

Currently looking into a fix, at first glance this seems due to the modalPresentationStyle we are setting.

8reactions
giekuscommented, Apr 29, 2021

This issue is now a problem on IOS 14.5 official version, this is causing a lot of issues. 😦

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found