2017-12-19 8 views
0

나는 react-native-keyboard-spacer를 사용하고 있습니다. 키보드를 자동으로 팝업하는 기능을 구현하고 싶습니다. 설명서에 나와 있습니다. onToggle method is called when when keyboard toggles. Two parameters passed through, keyboardState (boolean, true if keyboard shown) and keyboardSpace (height occupied by keyboard) 누구든지이 작업을 수행하는 방법을 보여줄 수 있습니까?react-native-keyboard-spacer onToggle을 사용하는 방법

답변

1

키보드가 전환 된 다음에 onToggle()은 으로 만 호출됩니다. 원하는 기능을 구현하려면 TextInput의 기본 제공 메서드를 사용하여 구성 요소가 장착을 마칠 때 입력에 집중하십시오.

componentDidMount() { 
    this._myTextInput.focus(); 
} 

render() { 
    return (
     <TextInput 
     style={{height: 40}} 
     ref={component => this._myTextInput = component} 
     /> 
    ); 
} 
1

onToggle 키보드를 표시하거나 숨길 때 호출됩니다. 사용자가 아무 것도 클릭하지 않고 키보드를 팝업하려면 textInput에서 focus()이 필요합니다.

관련 문제