2016-11-02 2 views
0
우리가 현재 반작용 네이티브 0.33

반작용 네이티브 심판은 텍스트 입력

우리는 그들이 다음 버튼을 쳤을 때 다른 1 개 텍스트 입력에서 이동합니다 심판을 사용하려고 실행하는

에 정의되지 않은. 암호에 대한 기본 사용자 이름입니다.

누구든지 아이디어가 있으십니까? 아래는 우리가 사용하는 코드입니다. 스택에서 발견 한 다른 게시물에서 이것은 그들이 한 일입니다. 그러나 이것이 우리에게 말하고있는 것은 .refs는 정의되지 않았다. 작동 렌더링 원래의 내부에 난 그냥 탐색기로하지만, renderScene 기능에 아래의 코드를 렌더링하는 경우

UPDATE는 그래서 나는

render() { 
    return (
     <Navigator 
      renderScene={this.renderScene.bind(this)} 
      navigator={this.props.navigator} 

      navigationBar={ 
      <Navigator.NavigationBar style={{backgroundColor: 'transparent'}} 
       routeMapper={NavigationBarRouteMapper} /> 
      } /> 
    ); 
    } 

까지 문제를 축소 한 것이 작동하지 않습니다. 아무도 이유를 아나요? 또는 네비게이터를 표시하고 renderScene의 코드를 원래 렌더링에 표시하는 방법은 무엇입니까?

class LoginIOS extends Component{ 

    constructor(props) { 
    super(props); 
    this.state={ 
     username: '', 
     password: '', 
     myKey: '', 
    }; 
    } 

    render() { 
    return (
     <Navigator 
      renderScene={this.renderScene.bind(this)} 
      navigator={this.props.navigator} 

      navigationBar={ 
      <Navigator.NavigationBar style={{backgroundColor: 'transparent'}} 
       routeMapper={NavigationBarRouteMapper} /> 
      } /> 
    ); 
    } 

    renderScene() { 
    return (
     <View style={styles.credentialContainer}> 
       <View style={styles.inputContainer}> 
        <Icon style={styles.inputPassword} name="person" size={28} color="#FFCD00" /> 
         <View style={{flexDirection: 'row', flex: 1, marginLeft: 2, marginRight: 2, borderBottomColor: '#e0e0e0', borderBottomWidth: 2}}> 
         <TextInput 
          ref = "FirstInput" 
          style={styles.input} 
          placeholder="Username" 
          autoCorrect={false} 
          autoCapitalize="none" 
          returnKeyType="next" 
          placeholderTextColor="#e0e0e0" 
          onChangeText={(text) => this.setState({username: text})} 
          value={this.state.username} 
          onSubmitEditing={(event) => { 
           this.refs.SecondInput.focus(); 
          }} 
          > 

         </TextInput> 
         </View> 
       </View> 

       <View style={styles.inputContainer}> 
        <Icon style={styles.inputPassword} name="lock" size={28} color="#FFCD00" /> 
         <View style={{flexDirection: 'row', flex: 1, marginLeft: 2, marginRight: 2, borderBottomColor: '#e0e0e0', borderBottomWidth: 2}}> 
         <TextInput 
          ref = "SecondInput" 
          style={styles.input} 
          placeholder="Password" 
          autoCorrect={false} 
          secureTextEntry={true} 
          placeholderTextColor="#e0e0e0" 
          onChangeText={(text) => this.setState({password: text})} 
          value={this.state.password} 
          returnKeyType="done" 
          onSubmitEditing={(event)=> { 
           this.login(); 
          }} 
          focus={this.state.focusPassword} 
          > 
         </TextInput> 
         </View> 
       </View> 
     </View> 
    ); 
    } 
+0

문제를 해결하기위한 시도 : 생성자에서 렌더링 장면 함수를 바인딩 해보십시오. 그래서 다음 줄을 추가하십시오 : this.renderScene = this.renderScene.bind (this) –

+0

그걸로 행운이 없습니다. 생성자에서 bind와 render render가있는 곳에서 시도해 보았습니다. renderScene = {this.renderScene.bind (this)}. 그럼 그냥 생성자에서 그것을 시도했다. – wdlax11

+0

@AlexHarrison renderScene과 관련이 있다는 것을 알았습니다. 내비게이션 막대를 제거하고 원래 렌더링의 입력 값 만 반환하면 작동합니다. 그러나 탐색 바가 필요합니다. 어떤 생각? – wdlax11

답변

2

기능을 사용하여 참조를 설정해보십시오. 이처럼 :

<TextInput ref={(ref) => { this.FirstInput = ref; }} /> 

은 그럼 당신은 this.FirstInput 대신 this.refs.FirstInput와 기준에 액세스 할 수 있습니다

+0

예! 정말 고맙습니다!!! 나는 이것을 영원히 고치려고 노력해왔다! – wdlax11

+0

키보드 인식에 대한 경험이 있다면 잠재적으로 다른 문제를 볼 수 있습니다. - http://stackoverflow.com/questions/40391717/react-native-keyboard-aware-scroll-view-not-working-properly – wdlax11

0

당신이 필요합니다 원인 다음 (Navigator 문서 기준)에 네비게이터의 renderScene 콜백을 변경해보십시오 네비게이터 객체.

renderScene={(route, navigator) => this.renderScene(route, navigator)} 

그런 다음 'this'대신 'navigator'를 사용하여 참조 정보를 가져옵니다.

navigator.refs.SecondInput.focus() 
+0

이것 역시 시도해 보았고 행운이 없었습니다./ – wdlax11

+0

흠, 확실하지 않지만 renderScene() 함수를 수정하여 'route'및 'navigator'객체를 받습니까? –

관련 문제