参考:http://blog.csdn.net/lvdezhou/article/details/72730079
http://facebook.github.io/react-native/docs/textinput.html#selectionstate
//实现点击view后,让被view包裹的textInput组件获取到焦点
主要代码:
//设置焦点
onStartShouldSetResponder() {
var comment = this.refs.comment;
comment.focus();
}
//--------------------------------------------------
<View
style = {[styles.view_comment,{height: this.state.maxHeight + 10, }]}
onStartShouldSetResponder = {this.onStartShouldSetResponder.bind(this)}
>
<TextInput
ref = 'comment'
style = {[styles.textInput_comment,{height: height_comments}]}
onChange={this.onChange}
multiline = {true}
onContentSizeChange = {this.onContentSizeChange.bind(this)}
value = {this.state.text_comments}
>
</TextInput>
</View>
//------------------------------------------------------