Implementing UITextFieldDelegate with Swift

前端 未结 12 1275
后悔当初
后悔当初 2020-12-08 08:11

I have my ViewController class which implements UITextFieldDelegate. I have no auto complete for the funcs such as textFieldShouldBeginEditing. Is this a bug in XCode 6?

12条回答
  •  忘掉有多难
    2020-12-08 09:02

    // MARK:- ---> Textfield Delegates

    func textFieldDidBeginEditing(textField: UITextField) {
    
        print("TextField did begin editing method called")
    }
    
    func textFieldDidEndEditing(textField: UITextField) {
    
        print("TextField did end editing method called\(textField.text)")
    }
    
    func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
    
        print("TextField should begin editing method called")
        return true;
    }
    
    func textFieldShouldClear(textField: UITextField) -> Bool {
    
        print("TextField should clear method called")
        return true;
    }
    
    func textFieldShouldEndEditing(textField: UITextField) -> Bool {
        print("TextField should end editing method called")
        return true;
    }
    
    
    func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
        print("While entering the characters this method gets called")
        return true;
    }
    
    
    func textFieldShouldReturn(textField: UITextField) -> Bool {
    
        print("TextField should return method called")
        textField.resignFirstResponder();
        return true;
    }
    

提交回复
热议问题