此代码运行成功,但未在Android模拟器存储中找到屏幕截图。有什么问题?在手机存储中保存屏幕截图是否需要进行任何更改?
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native SnapShot!
</Text>
<Text style={styles.instructions}>
To get started, edit App.js
</Text>
<Text style={styles.instructions}>
{instructions}
</Text>
<Button
onPress={
() => {
captureScreen({
format: "jpg",
quality: 0.8
})
.then(
uri => console.log("Image saved to", uri),
error => console.error("Oops, snapshot failed", error)
);
}
}
title="capture"
color="#841584"
accessibilityLabel="Capture"
/>
</View>
);
答案 0 :(得分:1)
请使用以下模块将图像保存在本地存储https://github.com/francisco-sanchez-molina/react-native-store-photos-album
中import CameraRollExtended from 'react-native-store-photos-album'
<Button
onPress = {
() => {
captureScreen({
format: "jpg",
quality: 0.8
})
.then(
uri => {
CameraRollExtended.saveToCameraRoll({
uri: uri,
album: 'Name'
}, 'photo')
},
error => console.error("Oops, snapshot failed", error)
);
}
}
/>