ios - React Native - 禁用 iOS 键盘上的密码自动填充选项

标签 ios reactjs react-native ios11 expo

在 React Native 中,如何禁用或阻止键盘显示密码自动填充附件 View 选项? TextInput 似乎没有一个属性可以处理禁用此选项。 React Native TextInput Documentation 。我还在 React Native 之上使用 Expo

Password AutoFill was introduced in iOS 11

Image of Password AutoFill Accessory view option

这里有一篇文章提供了禁用密码自动填充附件的解决方案,但是我们如何使用 React Native 来实现这一点呢?

iOS 11 disable password autofill accessory view option?

最佳答案

来自 RN 文档:

For iOS 11+ you can set textContentType to username or password to enable autofill of login details from the device keychain.

这意味着将 textContentType 设置为与用户名或密码不同的内容应禁用 iOS 键盘上的自动填充。但我注意到,即使 textContentType 不是用户名或密码,在 TextInput 组件中将 secureTextEntry 属性设置为 true 也会启用自动填充。除一种特殊情况外,即 textContentType 设置为 “oneTimeCode” 时,情况都是如此。即使 secureTextEntry 为 true,这也会禁用自动填充。

当我想隐藏密码自动填充并仍将 secureTextEntry 设置为 true 时,我只需这样做:

<TextInput
  secureTextEntry
  textContentType="oneTimeCode"
/>

在其他情况下,textContentType 不是“用户名”“密码”,并且 secureTextEntry 为 false但仍然显示自动填充。将 textContentType 设置为 “oneTimeCode” 也适用于此。

<TextInput
  textContentType="oneTimeCode"
/>

这更像是一种黑客而不是解决方案,但它对我有用。

关于ios - React Native - 禁用 iOS 键盘上的密码自动填充选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48489479/

相关文章:

ios - 从父 View Controller 访问容器 View 中的 UIScrollView 内容偏移量

ios - 如何在 Swift 中枚举 ALAssetsGroup

css - 在 CSS 中使用图像 url 时,React 应用程序编译失败

javascript - 函数/对象字面量之前的问号意味着

javascript - 如何在 react native 应用程序的页面上自动执行用户操作

ios - 选择器 valueWithCGRect 没有已知的类方法

ios - Apple Mach-O 链接器错误 - GameCenter

javascript - 如何在传递 props 时访问所有元素 props,而不必在 React 中列出它们?

reactjs - 记住我所有的 react 组件是个好主意吗?

reactjs - React + Redux + Normalizr api 请求错误处理