问题描述
我有一个的UITextField
,并作为用户输入一些文字,我需要的文本字段从一个数组提出了一些话。
I have a UITextfield
, and as the user enters some text I need the text field to suggest some words from an array.
我到处都找过,似乎每个人都在创建表或东西来显示的建议。
I have looked all over and it seems everyone is creating a table or something to display the suggestions.
有没有一种方法,我可以自定义默认的iOS自动完成用我的源的建议?
Is there a way I can customise the default iOS autocompletion to use my source for the suggestions?
推荐答案
您不能覆盖默认拼写检查的UITextField自动完成,因为拼写检查自动完成的目的是纠正错误,由操作系统本身(处理你可以,但是,将其禁用)。
You can't override the "default" spell checking autocompletion in UITextField, because the spell checking autocompletion is intended to correct errors and is handled by the OS itself (you can, however, disable it).
这是大多数自动完成系统iOS的工作是使用非常有帮助UISearchDisplayController的方式。你不需要很多code的得到这个工作正常,但它确实需要一些屏幕房地产显示的反应(如Safari浏览器中的谷歌搜索)列表。
The way that most autocompletion systems work in iOS is using the very helpful UISearchDisplayController. You don't need a lot of code to get this working correctly, but it does require some screen real estate for showing a list of responses (like Google searches in Safari).
苹果sameple code体面一点来说明如何做到这一点。这是<一个href=\"http://developer.apple.com/library/ios/#sample$c$c/TableSearch/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007848\"相对=nofollow>可在这里。
Apple has a decent bit of sameple code to show how to do this. It's available here.
这篇关于更改拼写检查/自动完成源对UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!