问题
I have to implement a custom autosuggestion for UITextField> I have an array of words and when I start typing in a textfield then all words similar to the typed text should appear as auto suggestion, like normal auto suggestion in ios but more than one word. And When I tap on one of them it should trigger an event. I know how to done this with a tableview anybody know a method to done this with ios's look and feel?
回答1:
For this purpose I used the project linked below: http://cocoacontrols.com/platforms/ios/controls/autocompletiontableview
回答2:
A sexy look for a autocomplete:
UITextField + UITextFieldDelegate http://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=wepopover
Using UITableView you keep the data and apply an predicate on:
- (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
I didn't attach source code because isn't general and might confuse you.
回答3:
Make an array of NSString, and search the typed string in UITextfield delegate method textChanged:, then print strings in a tableView.
In fact this will work like a UISearchBar.
来源:https://stackoverflow.com/questions/10550163/giving-custom-autosuggestion-for-uitextfield-iphone