react native input 组件 存在光标的情况下 点击按钮不触发onpress 事件 点第二次才会触发事件,这个问题怎么解决??代码如下



  • react native input 组件 存在光标的情况下 点击按钮不触发onpress 事件 点第二次才会触发事件,这个问题怎么解决??代码如下

    <KeyboardAwareScrollView>
    <View>
    <Image source={require('../imgs/login_bg.png')} style={{width:Dimensions.get('window').width,resizeMode:'stretch'}}/>
    <View style={{paddingTop:ScreenUtils.scaleHeight(92),paddingLeft:ScreenUtils.scaleSize(84),paddingRight:ScreenUtils.scaleSize(84)}}>
    <View style={this.state.focusAccount ? styles.viewFocusStyle : styles.viewStyle}>
    <Image source={require('../imgs/login_zhanghao.png')} style={{width:ScreenUtils.scaleSize(28),height:ScreenUtils.scaleHeight(38),resizeMode:'contain'}}/>
    <ScrollView keyboardShouldPersistTaps={'handled'}>
    <TextInput
    style={styles.textInputStyle}
    underlineColorAndroid='transparent'
    onChangeText={(text) => this.upDateAccount(text)}
    onFocus={()=>this.focusAccount()}
    onBlur={()=>this.blurAccount()}
    value={this.state.account}
    placeholder='请输入邮箱或手机号码'
    />
    </ScrollView>
    </View>
    <View style={this.state.focusPassword ? styles.viewFocusStyle : styles.viewStyle}>
    <Image source={require('../imgs/login_mima.png')} style={{width:ScreenUtils.scaleSize(29),height:ScreenUtils.scaleHeight(38),resizeMode:'contain'}}/>
    <ScrollView keyboardShouldPersistTaps={'handled'}>
    <TextInput
    style={styles.textInputStyle}
    secureTextEntry={true}
    underlineColorAndroid='transparent'
    onChangeText={(text) => this.upDatePassword(text)}
    onFocus={()=>this.focusPassword()}
    onBlur={()=>this.blurPassword()}
    value={this.state.password}
    placeholder='请输入登陆密码'
    />
    </ScrollView>
    </View>
    <ScrollView keyboardShouldPersistTaps={'always'}>
    <TouchableNativeFeedback
    disabled={(this.state.account && this.state.password) ? false : true}
    onPress={this._onPressLoginButton}
    background={TouchableNativeFeedback.SelectableBackground()}>
    <View style={(this.state.account && this.state.password) ? styles.loginButtonTrueStyle : styles.loginButtonStyle}>
    <Text style={{fontSize: ScreenUtils.setSpText2(30),color:'#ffffff'}}>登录</Text>
    </View>
    </TouchableNativeFeedback>
    </ScrollView>
    <View style={{flexDirection:'row',justifyContent:"space-between",paddingLeft:ScreenUtils.scaleSize(12),paddingRight:ScreenUtils.scaleSize(12),marginTop:ScreenUtils.scaleHeight(26)}}>
    <Text numberOfLines={5} style={{color:'#febe00'}}>
    点我注册
    </Text>
    <Text numberOfLines={5}>
    忘记密码?
    </Text>
    </View>
    </View>
    </View>
    </KeyboardAwareScrollView>



  • 用一个scrollview把需要获得焦点的全部套起来,不是分别套起来