在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ HTML/ iOS 導(dǎo)航器
JavaScript 環(huán)境
計(jì)時(shí)器
Native 模塊(iOS)
入門
在設(shè)備上運(yùn)行
ProgressBarAndroid
iOS 應(yīng)用程序狀態(tài)
網(wǎng)絡(luò)
ToolbarAndroid
測(cè)試
輔助功能
網(wǎng)絡(luò)信息
DrawerLayoutAndroid
樣式表
手勢(shì)應(yīng)答系統(tǒng)
與現(xiàn)有的應(yīng)用程序集成
樣式
教程
不透明觸摸
調(diào)試 React Native 應(yīng)用
iOS 活動(dòng)指示器
導(dǎo)航器
無反饋觸摸
動(dòng)畫布局
Web 視圖
鏈接庫
像素比率
React Native 官網(wǎng)首頁介紹
iOS 導(dǎo)航器
交互管理器
全景響應(yīng)器
SwitchAndroid
TabBarIOS.Item
相機(jī)滾動(dòng)
ToastAndroid
iOS 震動(dòng)
BackAndroid
文本輸入
iOS 選擇器
應(yīng)用程序注冊(cè)表
iOS 開關(guān)
滾動(dòng)視圖
iOS 日期選擇器
iOS 警告
iOS 鏈接
視圖
圖片
列表視圖
異步存儲(chǔ)
Native UI 組件(Android)
iOS 滑塊
Map 視圖
高亮觸摸
iOS 推送通知
文本
定位
iOS 狀態(tài)欄
Native UI 組件(iOS)
在設(shè)備上運(yùn)行(Android)
Native 模塊(Android)
Flexbox
已知 Issues
iOS 選項(xiàng)卡
安裝 Android 運(yùn)行環(huán)境

iOS 導(dǎo)航器

iOS 導(dǎo)航器包裝了 UIKit 導(dǎo)航,并且允許你添加跨應(yīng)用程序的 back-swipe 功能。

路線

路線是用于描述導(dǎo)航器每個(gè)頁面的一個(gè)對(duì)象。第一個(gè)提供給 NavigatorIOS 的路線是 initialRoute

render: function() {
  return (
    <NavigatorIOS
      initialRoute={{
        component: MyView,
        title: 'My View Title',
        passProps: { myProp: 'foo' },
      }}
    />
  );
},

現(xiàn)在將由導(dǎo)航器呈現(xiàn) MyView。它將在 route 道具,導(dǎo)航器及所有的 passProps 指定的道具中接受一個(gè)路線對(duì)象。

路線完整的定義請(qǐng)看 initialRoute propType。

導(dǎo)航器

Navigator 是視圖能夠調(diào)用的導(dǎo)航函數(shù)的一個(gè)對(duì)象。它作為一個(gè)道具會(huì)被傳遞給任何由 NavigatorIOS 呈現(xiàn)的組件。

var MyView = React.createClass({
  _handleBackButtonPress: function() {
    this.props.navigator.pop();
  },
  _handleNextButtonPress: function() {
    this.props.navigator.push(nextRoute);
  },
  ...
});

一個(gè)導(dǎo)航對(duì)象包含以下功能:

  • push(route)——導(dǎo)航到一個(gè)新的路線
  • pop()——返回一個(gè)頁面
  • popN(n)——一次返回 N 頁。當(dāng) N=1 時(shí),該行為相當(dāng)于 pop()
  • replace(route)——取代當(dāng)前頁面的路線,并立即為新路線加載視圖
  • replacePrevious(route)——取代前一頁的路線/視圖
  • replacePreviousAndPop(route)——取代了以前的路線/視圖并轉(zhuǎn)換回去
  • resetTo(route)——取代頂級(jí)的項(xiàng)目并 popToTop
  • popToRoute(route)——為特定的路線對(duì)象回到項(xiàng)目
  • popToTop()——回到頂級(jí)項(xiàng)目

導(dǎo)航功能在 NavigatorIOS 組件中也是可用的:

var MyView = React.createClass({
  _handleNavigationRequest: function() {
    this.refs.nav.push(otherRoute);
  },
  render: () => (
    <NavigatorIOS
      ref="nav"
      initialRoute={...}
    />
  ),
});

Props

Edit on GitHub

initialRoute {組件:函數(shù)型,標(biāo)題:字符串型,passProps:對(duì)象型,backButtonTitle:字符串型,rightButtonTitle:字符串型,onRightButtonPress:函數(shù)型,wrapperStyle:[對(duì)象型Object]}

NavigatorIOS 使用“路線”對(duì)象來識(shí)別子視圖,道具,及導(dǎo)航欄的配置?!皃ush”和所有其他的導(dǎo)航操作預(yù)計(jì)路線是這樣的:

itemWrapperStyle View#style

默認(rèn)的包為 navigator 中的組件設(shè)置樣式。一個(gè)常見的用例是為每一頁設(shè)置 backgroundColor

tintColor 字符串型

在導(dǎo)航欄中的按鈕使用的顏色

例子

Edit on GitHub

'use strict';
var React = require('react-native');
var ViewExample = require('./ViewExample');
var createExamplePage = require('./createExamplePage');
var {
  PixelRatio,
  ScrollView,
  StyleSheet,
  Text,
  TouchableHighlight,
  View,
} = React;
var EmptyPage = React.createClass({
  render: function() {
    return (
      <View style={styles.emptyPage}>
        <Text style={styles.emptyPageText}>
          {this.props.text}
        </Text>
      </View>
    );
  },
});
var NavigatorIOSExample = React.createClass({
  statics: {
    title: '<NavigatorIOS>',
    description: 'iOS navigation capabilities',
  },
  render: function() {
    var recurseTitle = 'Recurse Navigation';
    if (!this.props.topExampleRoute) {
      recurseTitle += ' - more examples here';
    }
    return (
      <ScrollView style={styles.list}>
        <View style={styles.line}/>
        <View style={styles.group}>
          <View style={styles.row}>
            <Text style={styles.rowNote}>
              See &lt;UIExplorerApp&gt; for top-level usage.
            </Text>
          </View>
        </View>
        <View style={styles.line}/>
        <View style={styles.groupSpace}/>
        <View style={styles.line}/>
        <View style={styles.group}>
          {this._renderRow(recurseTitle, () => {
            this.props.navigator.push({
              title: NavigatorIOSExample.title,
              component: NavigatorIOSExample,
              backButtonTitle: 'Custom Back',
              passProps: {topExampleRoute: this.props.topExampleRoute || this.props.route},
            });
          })}
          {this._renderRow('Push View Example', () => {
            this.props.navigator.push({
              title: 'Very Long Custom View Example Title',
              component: createExamplePage(null, ViewExample),
            });
          })}
          {this._renderRow('Custom Right Button', () => {
            this.props.navigator.push({
              title: NavigatorIOSExample.title,
              component: EmptyPage,
              rightButtonTitle: 'Cancel',
              onRightButtonPress: () => this.props.navigator.pop(),
              passProps: {
                text: 'This page has a right button in the nav bar',
              }
            });
          })}
          {this._renderRow('Pop', () => {
            this.props.navigator.pop();
          })}
          {this._renderRow('Pop to top', () => {
            this.props.navigator.popToTop();
          })}
          {this._renderRow('Replace here', () => {
            var prevRoute = this.props.route;
            this.props.navigator.replace({
              title: 'New Navigation',
              component: EmptyPage,
              rightButtonTitle: 'Undo',
              onRightButtonPress: () => this.props.navigator.replace(prevRoute),
              passProps: {
                text: 'The component is replaced, but there is currently no ' +
                  'way to change the right button or title of the current route',
              }
            });
          })}
          {this._renderReplacePrevious()}
          {this._renderReplacePreviousAndPop()}
          {this._renderPopToTopNavExample()}
        </View>
        <View style={styles.line}/>
      </ScrollView>
    );
  },
  _renderPopToTopNavExample: function() {
    if (!this.props.topExampleRoute) {
      return null;
    }
    return this._renderRow('Pop to top NavigatorIOSExample', () => {
      this.props.navigator.popToRoute(this.props.topExampleRoute);
    });
  },
  _renderReplacePrevious: function() {
    if (!this.props.topExampleRoute) {
      // this is to avoid replacing the UIExplorerList at the top of the stack
      return null;
    }
    return this._renderRow('Replace previous', () => {
      this.props.navigator.replacePrevious({
        title: 'Replaced',
        component: EmptyPage,
        passProps: {
          text: 'This is a replaced "previous" page',
        },
        wrapperStyle: styles.customWrapperStyle,
      });
    });
  },
  _renderReplacePreviousAndPop: function() {
    if (!this.props.topExampleRoute) {
      // this is to avoid replacing the UIExplorerList at the top of the stack
      return null;
    }
    return this._renderRow('Replace previous and pop', () => {
      this.props.navigator.replacePreviousAndPop({
        title: 'Replaced and Popped',
        component: EmptyPage,
        passProps: {
          text: 'This is a replaced "previous" page',
        },
        wrapperStyle: styles.customWrapperStyle,
      });
    });
  },
  _renderRow: function(title: string, onPress: Function) {
    return (
      <View>
        <TouchableHighlight onPress={onPress}>
          <View style={styles.row}>
            <Text style={styles.rowText}>
              {title}
            </Text>
          </View>
        </TouchableHighlight>
        <View style={styles.separator} />
      </View>
    );
  },
});
var styles = StyleSheet.create({
  customWrapperStyle: {
    backgroundColor: '#bbdddd',
  },
  emptyPage: {
    flex: 1,
    paddingTop: 64,
  },
  emptyPageText: {
    margin: 10,
  },
  list: {
    backgroundColor: '#eeeeee',
    marginTop: 10,
  },
  group: {
    backgroundColor: 'white',
  },
  groupSpace: {
    height: 15,
  },
  line: {
    backgroundColor: '#bbbbbb',
    height: 1 / PixelRatio.get(),
  },
  row: {
    backgroundColor: 'white',
    justifyContent: 'center',
    paddingHorizontal: 15,
    paddingVertical: 15,
  },
  separator: {
    height: 1 / PixelRatio.get(),
    backgroundColor: '#bbbbbb',
    marginLeft: 15,
  },
  rowNote: {
    fontSize: 17,
  },
  rowText: {
    fontSize: 17,
    fontWeight: '500',
  },
});
module.exports = NavigatorIOSExample;
上一篇:TabBarIOS.Item下一篇:鏈接庫