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

4

2 回答 2

2

当我进行一些搜索时,我发现keyboardDistanceFromTextField了类的属性IQKeyboardmanager。您可以使用以下代码为特定的 textField 对象设置键盘距离:

YourDropDowntextFiled.keyboardDistanceFromTextField = 250;

因此,为您的文本文件使用这行代码,您可以轻松地显示可见的下拉列表。

我已经签入了演示,如下所示。一个我没有添加keyboardDistanceFromTextField,所以它只出现在键盘之后,而另一个我应用了正确的,所以它会显示离键盘很远的距离。

在此处输入图像描述

于 2017-03-09T09:50:58.650 回答
0

看看这个。您可以使用 RxSwift 进行紧凑的编码

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)

    }
于 2017-03-09T09:25:40.950 回答