如何解决Xamarin.Forms:在登录页面上禁用自动创建强密码 形式在iOS中
我们有一个登录页面,用户可以在其中输入我们通过电子邮件发送给他们的PIN码。
Xamarin.Forms应用程序使用<Entry IsPassword="True" />
,因此我们在键入时获得了很好的******* d功能。
但是,当用户尝试登录iPhone时,建议为该字段输入“强密码”。好像电话认为用户正在创建密码。 (请参见图片。)这会导致大量的混乱和次优的用户体验。
如何禁用此自动建议/自动填充功能?我们忽略了什么:-)
Iphone created a strong password for this app... when logging in
- 我们在仿真器中看不到。
- 我们知道用户可以在电话设置中禁用自动填充功能,但是用户不应该这样做。
- 将IsPassword更改为false可以解决此问题,但是密码可见。
- 我们还看到在密码解决之前删除电子邮件条目即可解决问题...但是我们需要电子邮件。
感谢/ Per
解决方法
在iOS 12中,您可能已经看到iOS在注册应用程序时建议使用强密码。这是iOS的新功能。
如果您要禁用它,则可以使用自定义渲染器
形式
创建自定义条目
namespace xxx
{
public class MyEntry:Entry
{
}
}
在iOS中
using UIKit;
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms;
using xxx.iOS;
using xxx;
[assembly: ExportRenderer(typeof(MyEntry),typeof(MyEntryRenderer))]
namespace xxx.iOS
{
public class MyEntryRenderer: EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.TextContentType = UITextContentType.Password;
// set it as NewPassword will appear the issue
//Control.TextContentType = UITextContentType.NewPassword;
}
}
}
}
,
将Control.SecureTextEntry
设置为false
将解决此问题。
在iOS中
using UIKit;
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms;
using xxx.iOS;
using xxx;
[assembly: ExportRenderer(typeof(MyEntry),typeof(MyEntryRenderer))]
namespace xxx.iOS
{
public class MyEntryRenderer: EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
// To disable the "Use Strong Password" given by iOS
Control.SecureTextEntry = false;
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。