android - 如何创建某种在应用程序加载后消失的启动画面/启动画面? ( native react )

标签 android ios react-native

我想知道如何解决一个启动屏幕,比方说它出现几秒钟然后被另一个 View 取代?

我想在第一次启动应用程序时使用它并覆盖一些网络。

最佳答案

这就是我解决加载屏幕的方法。我使用 Navigator Component。

在我的 index.android.js 中,我将 initialRoute 设置为我的 SplashPage/SplashScreen 类,然后在其中设置超时指向您要在特定时间后跳转到的 MainView 的链接。

index.android.js 中的我的导航器:

<Navigator
   initialRoute={{id: 'SplashPage'}}
   renderScene={this.renderScene}
   configureScene={(route) => {
       if (route.sceneConfig) {
           return route.sceneConfig;
       }
       return Navigator.SceneConfigs.HorizontalSwipeJump;
   }}
/>

我的初始路线类:

class SplashPage extends Component {

    componentWillMount () {
        var navigator = this.props.navigator;
        setTimeout (() => {
            navigator.replace({
                id: 'MainView', <-- This is the View you go to
            });
        }, 2000); <-- Time until it jumps to "MainView" 
    }
    render () {
        return (
            <View style={{flex: 1, backgroundColor: 'red', alignItems: 'center', justifyContent: 'center'}}>
                <Image style={{position: 'absolute', left: 0, top: 0, width: windowSize.width, height: windowSize.height}} source={require('image!splash_screen')}></Image>
            </View>
        );
    }
}

module.exports = SplashPage;

编辑

可能更有趣,因为它是“原生”的;) https://github.com/crazycodeboy/react-native-splash-screen

关于android - 如何创建某种在应用程序加载后消失的启动画面/启动画面? ( native react ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33390013/

相关文章:

javascript - 通过 React Native 中的辅助函数发送状态更新

android - 升级到 Phonegap3,项目没有正确加载所需的插件

android - 第一次触摸时 MotionLayout 视觉故障

iphone - iOS 单元测试 : How to set/update/examine firstResponder?

iphone - 为什么 AVCaptureStillImageOutput jpegStillImageNSDataRepresentation 会抛出带有 NULL 样本缓冲区的异常?

react-native - 如何在 React Native 中设置这样的文本?

react-native - react native 测试-立即行动

java - 是否可以将函数值存储在哈希表中?

android - 如何使用索引直接从raw/res文件夹访问音频文件

iphone - iOS 拨号助手自动将本地号码格式化为美国号码