title: In React Native, How Can I Use KeyboardAvoidingView with a Modal in iOS?
body: <p>I am having trouble getting a KeyboardAvoidingView to work in iOS, specifically when wrapping a Modal in it. Testing in Android, the Modal avoids the keyboard correctly, but in iOS the keyboard covers the Modal.</p>
  <p>Here is a reproducible example, using an iPhone X as my test device:</p>
  <pre class="lang-js prettyprint-override"><code>import React, {useState} from 'react';
  import {StyleSheet, ScrollView, View, Modal, TextInput, KeyboardAvoidingView, Button, SafeAreaView} from 'react-native';
  
  export default function App() {
      const [modalVisible, setModalVisible] = useState(false);
  
      return (
          &lt;View style={styles.container}&gt;
              &lt;Button title={&quot;Open Modal&quot;} onPress={() =&gt; setModalVisible(true)}/&gt;
              {modalVisible &amp;&amp; 
              &lt;KeyboardAvoidingView behavior={Platform.OS === &quot;ios&quot; ? &quot;padding&quot; : &quot;height&quot;}&gt;
                  &lt;Modal
                      animationType=&quot;slide&quot;
                      transparent={true}
                      visible={modalVisible}&gt;
                      &lt;SafeAreaView style={styles.safeAreaView}&gt;
                          &lt;View style={styles.modalContentContainer}&gt;
                              &lt;Button title={&quot;Close Modal&quot;} onPress={() =&gt; setModalVisible(false)}/&gt;
                              &lt;ScrollView&gt;
                                  &lt;View style={styles.textInputContainer}&gt;
                                      &lt;TextInput
                                          value={&quot;test 1&quot;}
                                          onChangeText={() =&gt; {}}
                                          onBlur={() =&gt; {}}
                                      /&gt;
                                  &lt;/View&gt;
                                  &lt;View style={styles.textInputContainer}&gt;
                                      &lt;TextInput
                                          value={&quot;test 2&quot;}
                                          onChangeText={() =&gt; {}}
                                          onBlur={() =&gt; {}}
                                      /&gt;
                                  &lt;/View&gt;
                                  &lt;View style={styles.textInputContainer}&gt;
                                      &lt;TextInput
                                          value={&quot;test 3&quot;}
                                          onChangeText={() =&gt; {}}
                                          onBlur={() =&gt; {}}
                                      /&gt;
                                  &lt;/View&gt;
                                  &lt;View style={styles.textInputContainer}&gt;
                                      &lt;TextInput
                                          value={&quot;test 4&quot;}
                                          onChangeText={() =&gt; {}}
                                          onBlur={() =&gt; {}}
                                      /&gt;
                                  &lt;/View&gt;
                              &lt;/ScrollView&gt;
                          &lt;/View&gt;
                      &lt;/SafeAreaView&gt;
                  &lt;/Modal&gt;
              &lt;/KeyboardAvoidingView&gt;}
          &lt;/View&gt;
      );
  }
  
  const styles = StyleSheet.create({
      container: {
          flex: 1,
          backgroundColor: '#fff',
          alignItems: 'center',
          paddingTop: 50
      },
      safeAreaView: {
          flex: 1,
          justifyContent: &quot;center&quot;,
          alignItems: &quot;center&quot;,
      },
      modalContentContainer: {
          margin: 100,
          backgroundColor: &quot;#d6d6d6&quot;,
          width: &quot;80%&quot;,
          height: &quot;60%&quot;,
          borderRadius: 10,
      },
      textInputContainer: {
          flex: 1,
          margin: 40,
          alignItems: &quot;center&quot;,
      }
  });
  </code></pre>
  <p>You will notice that when you open the Modal and tap on the last TextInput field, the keyboard comes up and covers the Modal. The Modal does not avoid the keyboard, as would be expected.</p>
  <p>Here is a screenshot from my testing in iOS, where it is not working:</p>
  <p><a href="https://i.stack.imgur.com/Ns3k0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ns3k0.png" alt="iOS not working" /></a></p>
  <p>And here is a screenshot from my testing in Android, where it is working:</p>
  <p><a href="https://i.stack.imgur.com/nuVO8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nuVO8.png" alt="Android working" /></a></p>
  <p><strong>Any ideas on how I can make a Modal avoid the keyboard in iOS?</strong></p>