2016-07-11 33 views

risposta

21

È possibile utilizzare un componente TouchableWithoutFeedback all'interno del componente modale una proprietà onPress che chiude il modal.

<Modal visible={booleanThatHandlesModalVisibility}> 
    <TouchableWithoutFeedback onPress={() => funcToHideModal()}> 
    <View> 
    ... 
    </View> 
    </TouchableWithoutFeedback> 
</Modal> 

Se si desidera una zona del modal che non nasconde il modal sulla stampa è possibile aggiungere un altro TouchableWithoutFeedback senza una proprietà onPress per catturare l'evento prima che il primo uno come questo:

<Modal visible={booleanThatHandlesModalVisibility}> 
    <TouchableWithoutFeedback onPress={() => funcToHideModal()}> 
    <View> 
     <TouchableWithoutFeedback> 
     <View>...</View> 
     </TouchableWithoutFeedback> 
    </View> 
    </TouchableWithoutFeedback> 
</Modal> 
+1

Ho risolto il mio problema con questa idea, anche se vedo che '' 'TouchableOpacity''' non ha' '' onPressOut''', e ho dovuto usare '' 'TouchableOpacity''' con un'azione vuota invece di' ' 'TouchableWithoutFeedback''' – samthui7

Problemi correlati