在 TextInput 中启用粘贴和选择 - React Native [英] Enable paste and selection within TextInput - React Native

查看:37
本文介绍了在 TextInput 中启用粘贴和选择 - React Native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 TextInput 中实现复制和粘贴,但似乎无法实现.当我长按 TextInput 时,我期待着一个工具提示,但没有任何反应.

I am trying to implement copy and paste within my TextInput but cant seem to achieve it. I was expecting a tooltip when I long-pressed on my TextInput, however nothing happens.

我了解剪贴板并知道如何实现它,但我似乎无法将粘贴选项弹出给用户.

I know about Clipboard and would know how to implement it, but I cant seem to get the paste option to pop to the user.

有什么想法可以实现这一目标吗?

Any ideas how I can achieve this?

<TextInput
                maxLength={29}
                autoCapitalize={'characters'}
                numberOfLines={1}
                keyboardType={'default'}
                underlineColorAndroid='transparent'
                autoCorrect={false}
                value={IBAN.printFormat(this.state.ibanInput)}
                returnKeyType={'next'}
                onChangeText={iban => this.verifyIban(iban)}
                style={[{ borderWidth: 1, borderRadius: 2, height: '100%', width: '100%', textAlign: 'center', fontSize: width/24 },

                ]}
              />

推荐答案

看看这个代码!:https://github.com/facebook/react-native/issues/18926#issuecomment-490541013

 <ScrollView
contentContainerStyle={Styles.contentContainerStyle}
keyboardShouldPersistTaps="handled"
removeClippedSubviews={false}>

 <KeyboardAvoidingView>

      <Text style={Styles.labelPageTitle}>
        {'bla bla bla'}
      </Text>
      <Text>
          {'bla bla bla'}
      </Text>
      <TextInput
        onChangeText={text => this.setState({ title: text })}
        style={Styles.textInput}
        value={title}
      />

</KeyboardAvoidingView>

这篇关于在 TextInput 中启用粘贴和选择 - React Native的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆