laurentiuungur / luautocompleteview Goto Github PK
View Code? Open in Web Editor NEWHighly configurable autocomplete view that is attachable to any UITextField
License: MIT License
Highly configurable autocomplete view that is attachable to any UITextField
License: MIT License
If you just add one tiny little line it may be helpful to people!
view.addSubview(autoCompleteView)
Thanks for this, it's awesome and super handy!
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x1c0c6f180 "LUAutocompleteView.LUAutocompleteView:0x109e991f0.leading"> and <NSLayoutXAxisAnchor:0x1c0c61480 "UITextField:0x10a0f7400.leading"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.'
I have a textfield in a cell in a static table view, and I got this error after setting autocompleteView.textField = myTextField
in viewDidLoad()
It would be very good to use left images for each cell.
Also background can be dimmed while selecting an item from the list.
Thank you.
fileprivate let elements = (1...100).map { "\($0)" }
I have declared it above
extension ViewController: LUAutocompleteViewDataSource {
func autocompleteView(_ autocompleteView: LUAutocompleteView, elementsFor text: String, completion: @escaping ([String]) -> Void) {
// error found on this line.
let elementsThatMatchInput = elements.filter { $0.lowercased().contains(text.lowercased()) }
completion(elementsThatMatchInput)
}
}
Hello !! I have some issue found
If I use 2 textfields to use autocomplete I have change autocompleteView.textfield when textfield beginEditing. The auto complete TableView will always show at second textfield.
When I tap element in tableview. Delegate is not work.
Thank you ^
Hi,
is feature that open sugestion view after user touch edittext?
Cannot convert value of type '[String : AnyObject]?' to expected argument type '[NSAttributedStringKey : Any]?'
I had changed:
public var textAttributes: [String: Any]?
To
public var textAttributes: [NSAttributedStringKey : Any]?
I'd love to see an option to show all suggestions when a textfield is tapped. So when a textfield is currently blank, and a user taps it, it would dropdown showing all suggestions. Then if they start typing it would refine as normal.
After implementing the LUAutocompleteView, its working fine most of the time. But, sometimes the constraints issue is coming after the responding textfield which delegate with LUAutocompleteView. That is, what are the subView constraints which depends or neighbour for that textfield will not working.
Sample log:
( "<NSLayoutConstraint:0x60000048da20 V:[UITextField:0x7f9ff31de600]-(5)-[UIImageView:0x7f9ff25b6290] (active)>", "<NSLayoutConstraint:0x60000048db10 UILabel:0x7f9ff25be000'Certification Number'.height == UILabel:0x7f9ff25bdd20'Certification Name'.height (active)>", "<NSLayoutConstraint:0x60000048db60 V:[UIImageView:0x7f9ff25b6290]-(15)-[UILabel:0x7f9ff25be000'Certification Number'] (active)>", "<NSLayoutConstraint:0x60000048dc00 V:[UILabel:0x7f9ff25be000'Certification Number']-(10)-[UITextField:0x7f9ff31a8800] (active)>", "<NSLayoutConstraint:0x60000048dcf0 V:[UITextField:0x7f9ff31a8800]-(5)-[UIImageView:0x7f9ff25b6b00] (active)>", "<NSLayoutConstraint:0x60000048dde0 V:[UIImageView:0x7f9ff25b6b00]-(15)-[UILabel:0x7f9ff25bb010'Issue Date'] (active)>", "<NSLayoutConstraint:0x60000048de80 V:[UILabel:0x7f9ff25bb010'Issue Date']-(10)-[UITextField:0x7f9ff31db200] (active)>", "<NSLayoutConstraint:0x60000048df70 V:[UITextField:0x7f9ff31db200]-(5)-[UIImageView:0x7f9ff25bbc10] (active)>", "<NSLayoutConstraint:0x60000048e060 UILabel:0x7f9ff25be2e0'Country'.height == UILabel:0x7f9ff25bdd20'Certification Name'.height (active)>", "<NSLayoutConstraint:0x60000048e0b0 V:[UIImageView:0x7f9ff25bbc10]-(15)-[UILabel:0x7f9ff25be2e0'Country'] (active)>", "<NSLayoutConstraint:0x60000048e150 V:[UILabel:0x7f9ff25be2e0'Country']-(10)-[UITextField:0x7f9ff31ba000] (active)>", "<NSLayoutConstraint:0x600000495130 V:[UITextField:0x7f9ff31de600]-(0)-[MyProj..LUAutocompleteView:0x7f9ff24bd740] (active)>", "<NSLayoutConstraint:0x60000049d7e0 V:[UITextField:0x7f9ff31ba000]-(0)-[MyProj.LUAutocompleteView:0x7f9ff24bd740] (active)>" )
Sorry for English!
Am using Bluetooth keyboard for my app.
As the left and right arrow keys move the cursor in the text-field, using up and down arrow keys should select entries in the search result, and pressing return should select the entry and fill it in text-field.
Is it possible?
Hi.
I want to use a full custom TableViewCell, and be able to set some fields.
So, ideally, I need a delegate for cellForRowAt :)
Thanks!
Hello
Can I change the direction of autocomplete list to top or others?
Thank you
I want to use two autocomplete text field i.e. one for showing Int array list and other is for string array list (city list) but in LUAutocompleteViewDataSource it's not working?Please help me to solved above problem?
below is my source code:
//
// ViewController.swift
// LUAutocompleteViewExample
//
// Created by Laurentiu Ungur on 24/04/2017.
// Copyright © 2017 Laurentiu Ungur. All rights reserved.
//
import UIKit
import LUAutocompleteView
final class ViewController: UIViewController {
// MARK: - Properties
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var mNameTextField: UITextField!
private let autocompleteView = LUAutocompleteView()
private let autocompleteView2 = LUAutocompleteView()
private let elements = (1...100).map { "\($0)" }
private let cityName = ["abc", "xyz", "uoe", "kjo", "poi", "qwe"].map { "\($0)" }
// var mArray = [String]()
// MARK: - ViewController
override func viewDidLoad() {
super.viewDidLoad()
// mArray = cityName.map { "\($0)" }
view.addSubview(autocompleteView)
view.addSubview(autocompleteView2)
autocompleteView.textField = textField
autocompleteView.dataSource = self
autocompleteView.delegate = self
autocompleteView2.textField = mNameTextField
autocompleteView2.dataSource = self
autocompleteView2.delegate = self
// Customisation
autocompleteView.rowHeight = 45
autocompleteView.autocompleteCell = CustomAutocompleteTableViewCell.self // Uncomment this line in order to use customised autocomplete cell
autocompleteView2.rowHeight = 60
}
}
// MARK: - LUAutocompleteViewDataSource
extension ViewController: LUAutocompleteViewDataSource {
func autocompleteView(_ autocompleteView: LUAutocompleteView, elementsFor text: String, completion: @escaping ([String]) -> Void) {
if textField == mNameTextField{
let elementsThatMatchInput_int = cityName.filter { $0.lowercased().contains(text.lowercased()) }
completion(elementsThatMatchInput_int)
}else if textField == textField{
let elementsThatMatchInput = elements.filter { $0.lowercased().contains(text.lowercased()) }
completion(elementsThatMatchInput)
}
}
}
// MARK: - LUAutocompleteViewDelegate
extension ViewController: LUAutocompleteViewDelegate {
func autocompleteView(_ autocompleteView: LUAutocompleteView, didSelect text: String) {
print(text + " was selected from autocomplete view")
print("mNameTextField.text: \(mNameTextField.text!)")
print("textField: \(textField.text!)")
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.