Does anyone know why the image may not be loading? index.ios.js is below, rest of the code is simply generated from
react-native init TestApp
I am not sure if the opening and closing tags are wrong or what. The image appears to load when I put it into my browser.
import React, { Component } from 'react';
var MOCKED_MOVIES_DATA = [
{title: 'Title', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}},
];
import {
AppRegistry,
Image,
StyleSheet,
Text,
View
} from 'react-native';
export default class TestApp extends Component {
render() {
var movie = MOCKED_MOVIES_DATA[0];
return (
<View style={styles.container}>
<Text>{movie.title}</Text>
<Text>{movie.year}</Text>
<Image source={{uri: movie.posters.thumbnail}}
style={styles.thumbnail}
/>
</View>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
thumbnail: {
width: 53,
height: 81,
},
});
AppRegistry.registerComponent('TestApp', () => TestApp);
Add to your Info.plist
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
The problem is that you are trying to load the image from a http connection and not from a https connection as recommended by apple.
You can fix it by editing info.plist as answered by Kawatare267
You can see more details here
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.