Reputation: 131
I am currently developing in react native application for the iOS (i am a web developer). My application needs time to load some staff and open the keyboard on startup. I want to make the splash screen of the application a little bit longer (an additional 1 sec). how can i achieve that in xCode/react-native. Thank you a lot.
Upvotes: 3
Views: 3534
Reputation: 1433
The actual iOS splash screen cannot have any functionality, it just displays as long as it takes for the app to start.
However, you can achieve what you want to do by making the initial screen of your app look like the splash screen.
Rather than waiting one second, you should probably just wait until your data is loaded. Here is an example of that.
var MyApp = React.createClass({
getInitialState: function() {
return {loaded: false, data: null};
},
componentWillMount: function() {
fetch('http://example.com/data.json')
.then(res => {
self.setState({
data: res,
loaded: true,
});
},
render: function() {
if(this.state.loaded) {
return <MainApp />;
} else {
return <LoadingScreen />;
}
}
});
Upvotes: 5
Reputation: 336
Easy way would be to create a view controller with the same background image as the splash screen. When you are done loading your data, move on to the next view controller.
Good practice would be to put some kind of animation/indicator that you are loading some data and the waiting is intentional.. you don't want the user to think the app is stuck and close it.
Upvotes: 0