Hi together,
I just joined this forum because I just started tp learn programming with swift.
I'm using XCode 11 with swift and want to try to create an app for my IOS devices
I'm gained a litle experienced with perl ......
My very first question is how to get the active or activated UITextField after selecting?
I've two UITextFields and want to assign a date from the datepicker to assign the selected date to that UITextField I selected before.
Or I want to get the object I selectedfor further processing.
I just tried something like this to enter a text in the UITextField.text I selected before:
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var text1: UITextField! @IBOutlet weak var text2: UITextField! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. text1.addTarget(self, action: #selector(eventHappened), for: .touchDown) } @objc func eventHappened(textfield: UITextField) { print ("hallo") textfield.text = "hallo" }
}
Thank's for any advice