【发布时间】:2020-01-23 16:39:52
【问题描述】:
我在我的应用程序中使用https://github.com/ivpusic/react-native-image-crop-picker,当相机打开时我可以拍照,但是当我想选择它时,应用程序崩溃,有时一旦打开相机它就会崩溃,但是当我使用调试模式时它可以工作而是在 android 上在所有情况下都运行良好。
当我从 xcode 运行项目时工作正常,但不适用于 react-native run-ios --device "myDeviceName"
同样适用于更高版本的 ios,例如 13,它也能正常工作
- react-native-image-crop-picker ^0.23.1
- react-native v0.59.0
- IOS 9.3.6
调用打开相机时的组件:
ImagePicker.openCamera({
cropping: true,
width: 500,
height: 500,
includeExif: true,
includeBase64: true,
mediaType:"photo"
})
.then(image => {
this.setState({
cameraOpened: false
});
this.props.navigation.navigate("Preview", {
picture: image,
type: this.type,
state: this.props.navigation.state,
userId: this.userId
});
})
.catch(e => {
console.log(e);
this.setState({
cameraOpened: false
});
this.props.navigation.goBack();
});
}
Preview.js:
ImageEditor.cropImage(
this.picture.path,
{
offset: { x: 0, y: 0 },
size: { width: 500, height: 500 },
displaySize: { width: 500, height: 500 }
},
res => {
// Change it to res
this._uploadPicture(this.picture.path, response => {
if (response.status == 200) {
this.props.savePicture(this.picture);
this.setState(
{
loading: false
},
() => {
this.navigation.goBack(key);
}
);
} else {
alert(response);
}
});
},
err => {
this.setState({
loading: false
});
alert(err);
}
);
有什么想法吗?谢谢
【问题讨论】:
标签: ios react-native