The code works fine on Android. But on IOS it takes two taps to take the picture. The weirdest thing was I added a spinner as well to see if the tap get registered. It does. It starts spinning but then won’t take the picture. This code works flawlessly on Android. TouchableOpacity,TouchableWithoutFeedback all work fine else where throughout the app. So I guess it’s something with the takePictureAsync() function on the IOS. This is my code below
The Camera Component
<View style={{borderRadius:20,overflow:'hidden',height:'75%',width:'90%',elevation:10,marginTop:40}}>
<Camera ref={ref => { this.camera = ref }} style={{ height: '100%', width: '100%' }} type={this.state.type}>
</Camera>
</View>
<View style={{paddingTop:20}}>
<TouchableWithoutFeedback
style={{ alignSelf: 'center' }}
onPress={this.takePicture}>
<Image source={require('../../assets/camera.png')}
style={{ height: 60, width: 60 }} />
</TouchableWithoutFeedback>
</View>
The TakePictureFunction
takePicture = async () => {
console.log("Pressed " + this.camera)
if (this.camera) {
console.log("Camera")
let photo = await this.camera.takePictureAsync();
this.setState({ imageUri: photo.uri })
}
}
I’ve tried using all the touchable’s still doesnt work in ios. Any ideas. Thank you