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

问题描述 投票:7回答:1

在React Native中,如何禁用或阻止键盘显示“密码自动填充”附件视图选项? 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?

ios reactjs react-native ios11 expo
1个回答
0
投票

从RN文档:

对于iOS 11+,您可以将textContentType设置为用户名或密码,以启用自动填充设备钥匙串中的登录详细信息。

我注意到在TextInput组件中将secureTextEntry prop设置为true,即使textContentType不是用户名或密码,也可以在iOS键盘上自动填充。当textContentType设置为“ oneTimeCode”时,除了一种特殊情况外,都是如此。即使secureTextEntry为true,这也会禁用自动填充。

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

<TextInput
  secureTextEntry
  textContentType="oneTimeCode"
/>

这比解决方案更像是骇客,但对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.