alwx / react-native-photo-view

Pinch-to-zoom view for React Native (both iOS and Android)
MIT License
816 stars 435 forks source link

Unable to load iOS container file #115

Open luqiuyuan opened 6 years ago

luqiuyuan commented 6 years ago

The component is not able to load file from the application container given the file path. Below is my code.

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  View
} from 'react-native';
import PhotoView from 'react-native-photo-view';

export default class testPV extends Component {
  render() {
    return (
      <View style={styles.container}>
        <PhotoView
          source={{uri: '/private/var/mobile/Containers/Data/Application/6EA85B2D-E3C5-41B2-B2E3-99EDCB111AA1/tmp/react-native-image-crop-picker/6EEA54AF-D1E2-86B4-A847-8CA0937F0C23.jpg'}}
          minimumZoomScale={0.5}
          maximumZoomScale={3}
          androidScaleType="center"
          onLoad={() => console.log("Image loaded!")}
          style={{width: 300, height: 300}} />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

AppRegistry.registerComponent('testPV', () => testPV);

When running the codes above, the following error occurs

img_0679

I am using react-native-photo-view@1.5.2 and react-native@0.46.4

luqiuyuan commented 6 years ago

PhotoView is able to load file from the container by using URI like file:///private/var/mobile/Containers/Data/Application/6EA85B2D-E3C5-41B2-B2E3-99EDCB111AA1/tmp/react-native-image-crop-picker/6EEA54AF-D1E2-86B4-A847-8CA0937F0C23.jpg

However, the Image component in RN is able to load file without the protocol (file://)

I think it might be less confusing if PhotoView can keep consistent with the Image component in RN.