반응형

TextField 6

[iOS, Swift] UITextField 특정 글자 제한하기

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { let allowedCharacters = CharacterSet(charactersIn: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuxyz").inverted let components = string.components(separatedBy: allowedCharacters) let filtered = components.join..

iOS/코드조각 2022.08.21

[iOS, Swift] UIAlertController 텍스트 입력창 추가하기

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. let alert = UIAlertController(title: "Simple", message: "Simple Message with TextField", preferredStyle: .alert) let defaultAction = UIAlertAction(title: "OK", style: .default) { (action) in } alert.addAction(defaultAction) alert.addTextField { (textField) in textField.delegate = self } self.present(alert, animated: true) 실행 결과

iOS/코드조각 2022.08.21

[iOS, Swift] 텍스트필드 AutoComplete 자동완성 기능

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. // AutoComplete String var suggestionsArray: [String] = ["자동완성"] override func viewDidLoad() { super.viewDidLoad() textField.delegate = self } extension ViewController: UITextFieldDelegate { // 자동완성 func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { return !autoCompleteTe..

iOS/코드조각 2022.07.13
반응형