swift-texfield在editDidEnd之后调用editDidBegin

时间:2019-05-20 12:12:19

标签: ios swift uitextfield ibaction iqkeyboardmanager

我有一个tableView celltextfield,它也显示picker,在这里显示过滤的数据列表,并按输入符号进行过滤。我正在使用IQkeyboardManagerMcPicker。 用户开始编辑时,picker呈现为模态。然后,如果从选择器列表中选择了值,则picker被取消。

问题是:当我在控制台上的键盘上点击done(调用didEndEditing)时,我看到的是应用程序调用{​​{1}}-然后是didEndEditing,然后处理再次在beginEditing输入代码

这是我的代码:

@IBAction func editDidBegin(_ sender: UITextField)

和在控制台上

class QuickOrderVC: UIViewController, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate {
/* some code */
@IBAction func editDidBegin(_ sender: UITextField) {
        print("didBegin")
        /* some code */
        McPicker.showAsPopover(data: [filteredArr], fromViewController: self, sourceView: sender as! UIView, doneHandler: { [weak self] (selections: [Int : String]) -> Void in
            if let first = selections[0]{
                /* some code */
                self?.dismissKeyboard()
                return
            }
            }, cancelHandler: { () -> Void in
                /* some code */
                print("Canceled Popover begin")
                self.dismissKeyboard()
        }, selectionChangedHandler: { (selections: [Int:String], componentThatChanged: Int) -> Void  in
            let newSelection = selections[componentThatChanged] ?? "Failed to get new selection!"
            print("Component \(componentThatChanged) changed value to \(newSelection)")
        })
    }
    var filteredArr = [String]()
    @IBAction func sizeTextEditingChanged(_ sender: UITextField) {
        /* some code */
        self.presentedViewController?.dismiss(animated: false, completion: {
            McPicker.showAsPopover(data: [filteredArr], fromViewController: self, sourceView: sender as! UIView, doneHandler: { [weak self] (selections: [Int : String]) -> Void in
                if let first = selections[0]{
                    /* some code */
                    print("done Popover edit")
                    self?.presentedViewController?.dismiss(animated: false, completion: nil)
                    print("done Popover dismiss")
                    /* some code */
                    self?.dismissKeyboard()
                    return
                }
                }, cancelHandler: { () -> Void in
                    /* some code */
                    print("Canceled Popover edit")
                    self.presentedViewController?.dismiss(animated: false, completion: nil)
                    print("Canceled Popover dismiss")
                    self.dismissKeyboard()
                    return
            }, selectionChangedHandler: { (selections: [Int:String], componentThatChanged: Int) -> Void  in
                let newSelection = selections[componentThatChanged] ?? "Failed to get new selection!"
                print("Component \(componentThatChanged) changed value to \(newSelection)")
            })
        })
    }
    @IBAction func editDidEnd(_ sender: UITextField) {
        print("did end")
        self.presentedViewController?.dismiss(animated: false, completion: nil)
        print("did end - dismiss")
        return
    }

0 个答案:

没有答案