2017-08-07 60 views
0

我建立了一個Appcication像簡單的社交媒體。用戶可以添加狀態,位置,來自YouTube的視頻和照片。但我有問題上傳多個圖像使用反應本機圖像選擇器。我讀過的文件,但我沒有任何想法解決這個問題如何添加多個圖像使用反應本機圖像選擇器

這裏是我的功能代碼

onPhotoPress() { 
const options = { 
    quality: 1.0, 
    maxWidth: 50, 
    maxHeight: 50, 
    storageOptions: { 
    skipBackup: true, 
    }, 
}; 
ImagePicker.launchImageLibrary(options, openPicker(), (response) => { 
    console.log('Response = ', response); 

    if (response.didCancel) { 
    console.log('User cancelled photo picker'); 
    } 
    else if (response.error) { 
    console.log('ImagePicker Error: ', response.error); 
    } 
    else if (response.customButton) { 
    console.log('User tapped custom button: ', response.customButton); 
    } 
    else { 
    const source = { uri: `data:image/jpeg;base64,${response.data}` }; 

    this.setState({ 
     avatarSource: source, 
     name: response.fileName, 
     data: response.data, 
     type: response.type, 
     path: response.uri, 
    }); 
    } 
}); 
} 

用於瀏覽圖片這是我的代碼

  {this.state.avatarSource !== null ? 
      <Image 
      source={this.state.avatarSource} 
      style={{ 
       flex: 1, 
       resizeMode: 'contain', 
       marginVertical: 12, 
      }} 
      /> : <View /> } 

這是圖片上傳單個圖像 enter image description here

所以你能幫助我,獲得多個圖像或給我建議另一個庫,我應該用來解決我的問題

回答

0

該庫作爲本機iOS圖像選擇器的基本橋樑而開始,我想保持這種狀態。因此,這裏不支持超出本地UIImagePickerController支持的功能。 多個圖像選擇,對作物工具的更多控制,以及景觀支持是本機iOS功能中缺少的東西 - 與我的圖書館無關。如果你需要這些東西,react-native-image-crop-picker對你來說可能是更好的選擇。

正如您在React Native Image Picker自述文件中看到的,您無法使用此模塊進行多個圖像選擇。你最好試着用React Native Image Crop Picker來做到這一點。