Giter Site home page Giter Site logo

laurentiuungur / luautocompleteview Goto Github PK

View Code? Open in Web Editor NEW
54.0 4.0 22.0 792 KB

Highly configurable autocomplete view that is attachable to any UITextField

License: MIT License

Ruby 5.30% Swift 94.70%
cocoapods pods swift ios autocomplete autocomplete-search xcode cocoa cocoa-touch carthage

luautocompleteview's People

Contributors

laurentiuungur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

luautocompleteview's Issues

Adjust Textfield position when typing.

I have integrated AutocompleteView in Table cell. So when I am typing in textfield the dropdown is not visible as keypad is open.
I do not want to hide the keypad. I want to adjust the position of textfield(Tableview).
Before Scroll
IMG_3958
After Scroll
IMG_3959

Just in the read me....

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!

Issue with Constraints

*** 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()

Use of unresolved identifier "elements"

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)
}
}

Have some trouble

Hello !! I have some issue found

  1. 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.

  2. When I tap element in tableview. Delegate is not work.

Thank you ^

subView background colour change?

I've changed the background colour to the cell, but when the cells are removed you can see the white view behind retracting.

Background colour of cell all ok
screen shot 2019-01-06 at 17 38 40

When clearing textField it exposed the white view that I'm unable to change the colour of?
screen shot 2019-01-06 at 17 38 47

Feature Request: Show all suggestions on tap

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.

Some times class constraints facing conflicts after textview responding

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!

Change list direction

Hello
Can I change the direction of autocomplete list to top or others?

Thank you

Two autocomplete of type [String] and [Int] not working in LUAutocompleteViewDataSource methods?

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!)")
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.