React Native的键盘遮挡问题(input/webview里)


2017-06-15

1:使用keyVoaidView来解决 注意要设置behavio=“absolute”,哎。记性差 好像拼错了

2:使用下面的代码,监听键盘,然后将webView拉高就可以了

import React, { Component } from 'react';  
import { Keyboard, TextInput } from 'react-native';  
  
class Example extends Component {  
  componentWillMount () {  
    this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);  
    this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);  
  }  
  
  componentWillUnmount () {  
    this.keyboardDidShowListener.remove();  
    this.keyboardDidHideListener.remove();  
  }  
  
  _keyboardDidShow () {  
    alert('Keyboard Shown');  
  }  
  
  _keyboardDidHide () {  
    alert('Keyboard Hidden');  
  }  
  
  render() {  
    return (  
      <TextInput  
        onSubmitEditing={Keyboard.dismiss}  
      />  
    );  
  }  
}  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM