UITextFields中的联系信息的快捷方式或自动填充 [英] Shortcuts or autofill for contact info in UITextFields

查看:49
本文介绍了UITextFields中的联系信息的快捷方式或自动填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用iOS的Safari浏览器时,遇到要求输入名称和地址的表单时,我会在键盘区域找到快捷方式.例如,当焦点位于名字字段中时,这是键盘.我可以点击罗伯特"而不是输入姓名.

When I'm in Safari in iOS, and I hit a form that requires I enter name and address, I get shortcuts in the keyboard area. For example, here is the keyboard when the focus is in a first name field. I can tap "Robert" instead of typing a name.

姓,电话,电子邮件,邮政编码等字段也会发生类似的情况.

A similar thing happens for fields for last name, phone, email, zip code.

我可以在本机iOS应用中的 UITextField 中得到类似的东西吗?有没有一种方法可以标记一个字段,以便键盘将提供这些快捷方式建议?

Can I get a similar thing in a native iOS app, in a UITextField? Is there a way to mark a field so that the keyboard will offer these shortcut suggestions?

推荐答案

您可以通过设置 UITextField autocorrectionType 来打开或关闭它. autocorrectionType 的默认值为 UITextAutocorrectionTypeDefault .这意味着您无需执行任何操作,默认情况下会显示该信息.

You can turn on or off it by set autocorrectionType of UITextField. Default value of autocorrectionType is UITextAutocorrectionTypeDefault . It means you don't need to do anything, by default it will be showed.

UITextAutocorrectionTypeYes;//开启

UITextAutocorrectionTypeYes; // Turn on

UITextAutocorrectionTypeDefault;//开启

UITextAutocorrectionTypeDefault; // Turn on

UITextAutocorrectionTypeNo;//关闭

UITextAutocorrectionTypeNo; // Turn off

但是除了设置的 autocorrectionType 值之外,您还需要确保设备的 Keyboards Setting 中的 Predictive 已打开.如果 Predictive 已关闭,则即使将 autocorrectionType 更改为 UITextAutocorrectionTypeYes ,也不会显示建议.

But beside of set autocorrectionType value, you need to make sure Predictive in Keyboards Setting of device is turned on. If Predictive is turned off, suggestion won't be displayed even you changed autocorrectionType to UITextAutocorrectionTypeYes.

更新

您可以更改 textContentType 进行选择,以显示建议类型.来自 Contacts 的建议.例如,您想要电话建议

You can change textContentType to choose with type of suggestion will be shown. Suggestions are from the Contacts. For example, you want phone suggestion

textField.textContentType = UITextContentTypeTelephoneNumber;

这篇关于UITextFields中的联系信息的快捷方式或自动填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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