React Native:Scrollview在Textbox外部单击

时间:2015-12-03 14:33:45

标签: react-native

我遇到了以下问题:我有一个包含两个文本框和一个文本按钮的视图。我在文本框中输入内容并单击文本按钮,我必须单击两次以使其实际工作。如果我用View替换Scrollview它可以工作。它有解决方法吗?

var TestScreen = React.createClass({
  render: function() {
    var self = this;
   return (
     <ScrollView>
       <TextInput
      placeholder='test' 
       style = {{
         height: 50, 
          backgroundColor: 'green',
       }} />
      <TextInput
      placeholder='test' 
       style = {{
         height: 50, 
          backgroundColor: 'blue',
       }} />
       <Text onPress={() => alert('click')} style = {{
       backgroundColor: 'orange', 
       }} > Text </Text>
     </ScrollView> 
   );
  }
})

1 个答案:

答案 0 :(得分:1)

您是否尝试将keyboardShouldPersistTaps='handled'添加到ScrollView道具?

<ScrollView keyboardShouldPersistTaps='handled'>  
   ...
</ScrollView> 
相关问题