teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

エラー内容を変更しました

2018/05/31 00:57

投稿

yamady
yamady

スコア176

title CHANGED
File without changes
body CHANGED
@@ -3,9 +3,7 @@
3
3
  しかし、現在エラーが出てしまい、困っています。
4
4
 
5
5
  ```
6
- JSON value '{
7
- uri = "file:///Users/sy/Library/Developer/CoreSimulator/Devices/2A298CC9-47DE-4E26-B236-F253373A575C/data/Containers/Data/Application/C9DA7950-01E1-4046-BF8E-BF1AFDF8F131/Documents/images/C11235A4-6529-4A01-A870-29315065C023.jpg";
8
- }' of type NSMutableDictionary cannot be converted to NSString
6
+ Warning: Failed prop type: Invalid prop `source` supplied to `Image`.
9
7
  ```
10
8
 
11
9
  **開発環境**
@@ -58,9 +56,10 @@
58
56
  }
59
57
  else {
60
58
  let source = { uri: response.uri };
59
+ console.log('source', source);
61
60
 
62
61
  // Image Resizer で 画像をリサイズする
63
- ImageResizer.createResizedImage(source, 800, 600, 'JPEG', 80)
62
+ ImageResizer.createResizedImage(source.uri, 800, 600, 'JPEG', 80)
64
63
  .then(({uri}) => {
65
64
  this.setState({
66
65
  ImageSource: uri,

1

エラー内容を変更しました

2018/05/31 00:57

投稿

yamady
yamady

スコア176

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,9 @@
3
3
  しかし、現在エラーが出てしまい、困っています。
4
4
 
5
5
  ```
6
- No suitable image URL loader found for (null)
6
+ JSON value '{
7
+ uri = "file:///Users/sy/Library/Developer/CoreSimulator/Devices/2A298CC9-47DE-4E26-B236-F253373A575C/data/Containers/Data/Application/C9DA7950-01E1-4046-BF8E-BF1AFDF8F131/Documents/images/C11235A4-6529-4A01-A870-29315065C023.jpg";
8
+ }' of type NSMutableDictionary cannot be converted to NSString
7
9
  ```
8
10
 
9
11
  **開発環境**
@@ -33,7 +35,7 @@
33
35
  errorUpload: false,
34
36
  };
35
37
 
36
- selectPhotoTapped() {
38
+ pickImage() {
37
39
  const options = {
38
40
  title: 'Select a Image',
39
41
  storageOptions: {
@@ -42,17 +44,7 @@
42
44
  }
43
45
  };
44
46
 
45
- ImageResizer.createResizedImage(this.state.ImageSource, 10, 10, 'PNG', 20)
46
- .then(({uri}) => {
47
- this.setState({
48
- resizedImageUri: uri,
47
+ // Image Picker で 画像を表示する
49
- });
50
- }).catch((err) => {
51
- console.log(err);
52
- return Alert.alert('Unable to resize the photo',
53
- 'Check the console for full the error message');
54
- });
55
-
56
48
  ImagePicker.showImagePicker(options, (response) => {
57
49
  console.log('Response = ', response);
58
50
  if (response.didCancel) {
@@ -66,8 +58,17 @@
66
58
  }
67
59
  else {
68
60
  let source = { uri: response.uri };
61
+
62
+ // Image Resizer で 画像をリサイズする
63
+ ImageResizer.createResizedImage(source, 800, 600, 'JPEG', 80)
64
+ .then(({uri}) => {
69
- this.setState({
65
+ this.setState({
70
- ImageSource: source,
66
+ ImageSource: uri,
67
+ });
68
+ }).catch((err) => {
69
+ console.log(err);
70
+ return Alert.alert('Unable to resize the photo',
71
+ 'Check the console for full the error message');
71
72
  });
72
73
  }
73
74
  });
@@ -79,7 +80,7 @@
79
80
  <Text>Image</Text>
80
81
  <TouchableOpacity
81
82
  style={styles.frame}
82
- onPress={this.selectPhotoTapped.bind(this)}
83
+ onPress={this.pickPhoto.bind(this)}
83
84
  >
84
85
  {
85
86
  this.state.ImageSource === null ?