在iOS中,除了图像不保存之外,一切都很好。相机捕获和检索图像组件的网址都很好。但是当我查看照片/图库时,捕获的照片不在那里。
我使用的选项:
var optionsIOS = {
title: 'Select Avatar',
cancelButtonTitle:'Cancel',
takePhotoButtonTitle:'Photo Capture',
chooseFromLibraryButtonTitle:'Choose from Gallery',
quality:0.5,
storageOptions: {
skipBackup: true,
}
};
要回答这个问题,您需要像这样将cameraRoll
道具设置为 true:
var optionsIOS = {
title: 'Select Avatar',
cancelButtonTitle:'Cancel',
takePhotoButtonTitle:'Photo Capture',
chooseFromLibraryButtonTitle:'Choose from Gallery',
quality:0.5,
storageOptions: {
cameraRoll: true,
skipBackup: true
}
};
你可以在这里找到所有不同的道具。
下面的代码是我在RN应用程序中用来保存图像的代码。
saveToCameraRoll = (image) => {
if (Platform.OS === 'android') {
RNFetchBlob
.config({
fileCache : true,
appendExt : 'jpg'
})
.fetch('GET', image.urls.small)
.then((res) => {
CameraRoll.saveToCameraRoll(res.path())
.then(Alert.alert('Success', 'Photo added to camera roll!'))
.catch(err => console.log('err:', err))
})
} else {
CameraRoll.saveToCameraRoll(image.urls.small)
.then(Alert.alert('Success', 'Photo added to camera roll!'))
}
}