0
votes

I found a weird problem in my iOS application written in Swift. Sometimes textfield does not work ie textfield does not detect touch and keyboard is not showing. All the textfields in every viewControllers suddenly stops working. Help is much appreciated thank you.

Edit: Adding some code

 override func viewDidLoad()
{
    super.viewDidLoad()

    oldPswdTextField.delegate = self
    newPswdTextField.delegate = self
    confirmPswdTextField.delegate = self
}

////On back button click///////

func resignAllResponsers()
{
    if oldPswdTextField.isFirstResponder
    {
        oldPswdTextField.resignFirstResponder()
    }
    else if newPswdTextField.isFirstResponder
    {
        newPswdTextField.resignFirstResponder()
    }
    else if confirmPswdTextField.isFirstResponder
    {
        confirmPswdTextField.resignFirstResponder()
    }
}

/////////////////

func textFieldShouldClear(_ textField: UITextField) -> Bool
{
    if textField.tag == 0
    {
        showPswdBtn.setImage(UIImage(named: "eyeClose.png"), for: UIControlState.normal)
    }
    else if textField.tag == 1
    {
        showNewPswdBtn.setImage(UIImage(named: "eyeClose.png"), for: UIControlState.normal)
    }

    return true
}

func textFieldShouldReturn(_ textField: UITextField) -> Bool
{
    textField.resignFirstResponder()
    return true;
}
1
Show your code. Seems like other overlay view is added up on your VC at some condition. - pkc456
in which scenatio u faced this, are you checking in simulator or device - Anbu.Karthik
I am checking this in actual device itself. Xcode Version 8.3.2 (8E2002) iOS version 10.3.2 - sreejesh
Everything else on the screen is working.., i can tap button, go back to previous screen etc. But textfield is not detecting any touch let alone calling any textField delegate. - sreejesh
is text field touch event worked at least once or not. Can u show some of your textfield related code part. - Krishnarjun Banoth

1 Answers

0
votes

I found the solution. The problem was because ui alert controllers were dismissing wrongly. After made it correct, textField problem was sorted out.