反应本机 捕获图像后显示自定义消息



我试图在用户捕获图像并将图像保存在图库中后向用户显示一条消息。我已经在网上冲浪,但找不到任何解决方案。到目前为止,我已经从这里尝试了以下代码来捕获图像-

takePicture = async function() {
if (this.camera) {
  this.camera.takePicture().then(data => {
    FileSystem.moveAsync({
      from: data,
      to: `${FileSystem.documentDirectory}photos/Photo_${this.state
        .photoId}.jpg`,
    }).then(() => {
      this.setState({
        photoId: this.state.photoId + 1,
      });
      Vibration.vibrate();
    });
  });
}
};

现在我想知道我应该怎么做才能获得完成事件。任何帮助都非常感谢。

我不是最好的代码中的内容,但您可以通过这种方式显示消息:

Toast.makeText(getApplicationContext(),"Picture taken!",Toast.LENGTH_SHORT).show();

您可以使用跨平台库代替 Toast:react-native-dropdown-alert

最新更新