gpt4 book ai didi

ios - 覆盖/禁用 TextInput 中的 iOS 智能标点符号

转载 作者:行者123 更新时间:2023-12-01 16:01:46 31 4
gpt4 key购买 nike

React Native 0.59.9,设备运行 iOS 11,并启用智能标点符号。此 iOS 功能会自动将输入的文本转换为更美观的符号。

例子:

  • 双连字符 --自动转换为 emdash (unicode 8212)
  • 引号"被自动转换为 curl 引号 (unicode 8220)

  • 等等。

    不幸的是,禁用智能标点符号(通过设置 > 通用 > 键盘)不是一个选项。

    我渲染了一个基本的 TextInput组件几乎完全符合 RN docs ,唯一的异常(exception)是我使用自己的 onChangeText处理函数以查看对输入文本的影响:
    import React, { Component } from 'react';
    import { TextInput } from 'react-native';


    function handleTextChange(value) {
    // check value here after entering a '-' in the rendered TextInput.
    // when initial value is set to '', received value is ascii 45
    // when initial value is set to '-', received value is unicode 8212
    }

    export default function UselessTextInput() {
    const [value, onChangeText] = React.useState('-'); // change this to '' to see the difference

    return (
    <TextInput
    style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
    onChangeText={(text) => handleTextChange(text)}
    value={value}
    />
    );
    }

    设置 autoCorrect={false}和/或 autoCompleteType='off'<TextInput>对输入的文本没有影响。

    问题
    有没有办法覆盖这种自动更正行为,以便不更改用户输入的数据?

    我看到有人通过 Github issue 向 Facebook RN 提出了这个问题,但没有得到回应。

    最佳答案

    它并不总是一种选择,但补充说:

    keyboardType={'ascii-capable'}
    到 TextInput 为我修复了它

    关于ios - 覆盖/禁用 TextInput 中的 iOS 智能标点符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57983965/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com