search
LoginSignup
0

More than 3 years have passed since last update.

posted at

React Native Navigation

create app

react-native init NaviTest

test

react-native run-ios

lib install

1 Install react-native-navigation latest stable version.

yarn add react-native-navigation@latest

2 Add ReactNativeNavigation.xcodeproj

以下をXCodeのライブラリに追加

./node_modules/react-native-navigation/ios/ReactNativeNavigation.xcodeproj

3 Build Phasesに追加

Build Phasesに追加

In Xcode, in Project Navigator (left pane), click on your project (top), then click on your target row (on the "project and targets list", which is on the left column of the right pane) and select the Build Phases tab (right pane). In the

スクリーンショット 2018-09-02 21.25.43.png

4 Build Settings

Build Settingsを選択
Allを選んだのち、検索BOXに Header Search を入力 

Header Search Pathsの行をダブルクリック、表示された領域に以下を入力
$(SRCROOT)/../node_modules/react-native-navigation/ios

スクリーンショット 2018-09-02 21.32.52.png

5 In Xcode, you will need to edit this file: AppDelegate.m

Replace @"index.ios" with @"index"

ここはすでになってれば必要ない

ソース変更

srcフォルダ作成

./src/app.js作成

import { Navigation } from 'react-native-navigation';

import { registerScreens } from './screens';

registerScreens(); // this is where you register all of your app's screens

// start the app
Navigation.startTabBasedApp({
  tabs: [
    {
      label: 'One',
      screen: 'example.FirstTabScreen', // this is a registered name for a screen
      icon: require('../img/one.png'),
      selectedIcon: require('../img/one_selected.png'), // iOS only
      title: 'Screen One'
    },
    {
      label: 'Two',
      screen: 'example.SecondTabScreen',
      icon: require('../img/two.png'),
      selectedIcon: require('../img/two_selected.png'), // iOS only
      title: 'Screen Two'
    }
  ]
});

screensフォルダ作成

index.jsを作成

import { Navigation } from 'react-native-navigation';

import FirstTabScreen from './FirstTabScreen';
import SecondTabScreen from './SecondTabScreen';
import PushedScreen from './PushedScreen';

// register all screens of the app (including internal ones)
export function registerScreens() {
  Navigation.registerComponent('example.FirstTabScreen', () => FirstTabScreen);
  Navigation.registerComponent('example.SecondTabScreen', () => SecondTabScreen);
  Navigation.registerComponent('example.PushedScreen', () => PushedScreen);
}

結果

どうやっても落ちる
うまくいかなさすぎて諦めた

いつか再挑戦します。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0