xcode how to know which textfield is selected
class ViewController : UIViewController, UITextFieldDelegate {
var activeTextField = UITextField()
// Assign the newly active text field to your activeTextField variable
func textFieldDidBeginEditing(textField: UITextField) {
self.activeTextField = textField
}
// Call activeTextField whenever you need to
func anotherMethod() {
// self.activeTextField.text is an optional, we safely unwrap it here
if let activeTextFieldText = self.activeTextField.text {
print("Active text field's text: \(activeTextFieldText)")
return;
}
print("Active text field is empty")
}
}
Also in Swift:
- swiftui font color
- swift how to make a variable
- swift uitextfield only numbers keyboard lock programmatically
- swift from 1 to 01
- use alamofire to login in swift 5
- swift change enum value
- swift thread.sleep
- swift writing to ios logs
- swift uitableview cell spacing
- how to dismiss a view when touch up inside swift
- xcode how to get aspect ratio of device
- how to change background color of stackview swift
- enum from raw value swift
- swift uitableview insert cell
- guard let swift
- set button programmatically swift
- sheet swiftui
- how to screen record swift stackoverflow
- swift open url
- how to set the center in view in swift
- deselect all cell in collectionview
- swift temporary directory
- switch statements swift
- UIFont.init bold