键盘抬起时无法按 TouchableOpacity。我需要双击它。反应本机

问题描述 投票:0回答:2

我正在使用 React-Native 为我的应用程序创建评论部分并为 ios 进行构建。当键盘要发表评论时,我无法立即按下提交帖子的 TouchableOpacity 按钮。我需要先按它关闭键盘,然后再按一次才能提交。

const CommentCreation = React.forwardRef((props, ref) => {
    
    return (
        <View style={commentCreationStyles.container} >
            <TextInput
                value={props.message}
                ref={ref}
                style={commentCreationStyles.input}
                onChangeText={val => props.setMessage(val)}
                autoFocus={false}
                multiline={true}
                returnKeyType={'next'}
                placeholder={'Enter Your Comment'}
                numberOfLines={5}
                replyBool={props.replyBool}
            />
            <TouchableOpacity
                style={commentCreationStyles.submitButton}
                onPress={props.addCommentEnabled ? () => {props.addComment(); Keyboard.dismiss()} : null}
            >
                <Ionicons name="ios-send" size={36} color="#D7D7D7" />
            </TouchableOpacity>
        </View>
    )
})

My app

除了 View 和替换 View 之外,我还尝试过 KeyboardShouldPersistTaps="handled" 及其变体与 ScrollView 结合使用。我已经在树的各个级别上尝试过这些。我很茫然,非常感谢任何帮助!

ios react-native
2个回答
0
投票

您解决过这个问题吗?我现在也遇到同样的问题了


-1
投票

在第一个视图中添加keyboardShouldPersistTaps='handled'作为

<View style={commentCreationStyles.container} keyboardShouldPersistTaps='handled' >
© www.soinside.com 2019 - 2024. All rights reserved.