我正在尝试使用react-native-navigation作为我的react-native中的导航系统。我编写了一个非常简单的应用程序来测试它,但是该应用程序在启动屏幕后崩溃(没有给我任何错误或信息)。
我的index.ios.js:
/* eslint-disable no-unused-vars */
import App from './src/app';
我的app.ios.js:
import {
Platform
} from 'react-native';
import {Navigation} from 'react-native-navigation';
import { registerScreens } from './screens';
registerScreens(); // this is where you register all of your app's screens
// this will start our app
Navigation.startTabBasedApp({
tabs: [{
label: 'One',
screen: 'AwesomeProject.Home', // this is a registered name for a screen
icon: require('../img/one.png'),
selectedIcon: require('../img/one_selected.png'), // iOS only
title: 'Screen One'
}]
});
我的screens.js
import { Navigation } from 'react-native-navigation';
import Home from './containers/Home';
import About from './containers/About';
// register all screens of the app (including internal ones)
export function registerScreens() {
Navigation.registerComponent('AwesomeProject.Home', () => Home);
Navigation.registerComponent('AwesomeProject.About', () => About);
}
我的 Home.js:
import React, { Component } from 'react';
import { Text } from 'react-native';
class Home extends Component {
render() {
return (
<Text>Home!</Text>
);
}
}
export default Home;
我的 About.js:
import React, { Component } from 'react';
import { Text } from 'react-native';
class About extends Component {
render() {
return (
<Text>About!</Text>
);
}
}
export default About;
您可以在此处查看完整要点:https://gist.github.com/inchr/d0184f4ae91abd6036a2fa61725744c9
我已经对如何在 startTabBasedApp() 中加载选项卡进行了非常多的测试,并且我也尝试过仅加载屏幕。
关于闪屏后崩溃/关闭的原因有什么想法吗?
谢谢。
最佳答案
好吧,问题是我运行后:react-native link
我忘记编辑 AppDelete.m 文件,如下所述: https://github.com/wix/react-native-navigation/wiki/Installation---iOS#installation---ios
https://github.com/wix/react-native-navigation/blob/master/example/ios/example/AppDelegate.m
关于react-native - 简单的 react native 应用程序(使用 react native 导航)在闪屏后崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43165439/