/** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow */ import React, { Component } from "react"; import { Platform, StyleSheet, Text, View, Image, TouchableOpacity, ImageBackground, TextInput, Button, StatusBar, Modal, TouchableHighlight, DeviceEventEmitter } from "react-native"; import ImagePicker from "react-native-image-picker"; type Props = {}; const options = {}; export default class ChosePhoto extends Component { state = { modalVisible: false }; setModalVisible(visible) { this.setState({ modalVisible: visible }); } render() { return ( { this.setState({ modalVisible: false }); }} > this.setState({ modalVisible: false })} > 拍照 从相册选择 { this.setState({ modalVisible: false }); }} > 取消 ); } photograph() { this.setModalVisible(false); //拍照 ImagePicker.launchCamera(options, response => { if (response.error) { alert("ImagePicker Error: " + response.error); } this.props.photoback(response.uri); }); } album_selection() { this.setModalVisible(false); //打开系统相册 ImagePicker.launchImageLibrary(options, response => { if (response.error) { alert("ImagePicker Error: " + response.error); } this.props.photoback(response.uri); }); } }