1

I have one Billing Address page in the app. I have to remember all text field data adds by the user and show them in a drop down list.

I have to create a table view on the bottom of the text fields. I am also using IQKeyboardManager for maintaining text fields when the keyboard appears.

So, when the keyboard appears, the table view is overlapping on the back of keyboard. How to resolve this issue?

I am also attaching the screenshot:

IQKeyboardManager toolbar in front of text field

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Gaurav Gupta
  • 593
  • 2
  • 10
  • 31

2 Answers2

2

As i doing some search i found keyboardDistanceFromTextField property of IQKeyboardmanager class. You can set disctance of keyboard for the specific textField object using following code:

YourDropDowntextFiled.keyboardDistanceFromTextField = 250;

So make use of this line of code for your textfiled and you can easily show the drop-down list visible.

I have checked in Demo look like following. One i did not add keyboardDistanceFromTextField so it just appear after keyboard and other i apply propery so it will show big distance from the keyboard.

enter image description here

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
0

Look This. You can use RxSwift for compact coding

var autoCompleteTableView: UITableView = UITableView()
let containerView: UIView = UIView()
var placesArray = Observable.just([String]())

func createAutocompleteContainer() {

        let screenSize: CGRect = UIScreen.mainScreen().bounds
        let width : CGFloat = screenSize.width-138
        let height : CGFloat = 200
        containerView.frame = CGRect(x: 130, y: 62, width: width, height: height)
        autoCompleteTableView.frame = CGRect(x: 0, y: 0, width: containerView.frame.size.width, height: containerView.frame.size.height)
        containerView.backgroundColor = UIColor.whiteColor()
        placesArray
            .bindTo(autoCompleteTableView.rx_itemsWithCellIdentifier("cell", cellType: UITableViewCell.self)) { (row, element, cell) in
                cell.textLabel?.text = "\(element)"
                cell.textLabel?.textColor = UIColor(hex: "#b2b2b2")
                cell.textLabel?.font = UIFont.systemFontOfSize(13)
            }
            .addDisposableTo(disposeBag)


        autoCompleteTableView
            .rx_modelSelected(String)
            .subscribeNext { value in
                self.textField = value
                self.containerView.removeFromSuperview()
            }
            .addDisposableTo(disposeBag)

        self.containerView.addSubview(autoCompleteTableView)
        self.view.addSubview(containerView)

    }