개발/아이오에스

swift] UITextFieldDelegate with Swift

dev.jake 2020. 12. 23. 16:32

stackoverflow.com/questions/24171857/implementing-uitextfielddelegate-with-swift

 

Implementing UITextFieldDelegate with Swift

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? Here's my class implemen...

stackoverflow.com

 

UITextFieldDelegate ..

func textFieldDidBeginEditing(_textField: UITextField) {
TextField가 편집을 시작
}
func textFieldDidEditing(_textField: UITextField) {
TextField에서 편집을 종료
}
func textFieldShowBeginEdit(_textField: UITextField) -> Bool {
텍스트 필드 편집 방법 호출 시작

}
func textFieldShouldClear(_textField: UITextField) -> Boole {
TextField는 호출된 메서드를 지워야 함

}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
문자를 입력하는 동안 이 메서드가 호출됨
}

 

func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {

        print("textFieldShouldEndEditing")

        if textField.text != ""{

            return true

        }

        else{

            textField.placeholder = "도시를 입력해주세요"

            return false

        }

    }//입력이 끝낫는데 텍스트필드 값이 ""이라면 false -> false이면 키보드가 내려가지않고 편집이 종료되지 않음