I have an identical question about this , but since I'm new to programming and only know quickly, I was wondering if anyone could give me its equivalent soon. Or point me to another question that I might have missed, it's quick.
Thanks!
UPDATE: here is the main point of my view controller after I cut off some of the fat in order to deal only with the relevant topic. To repeat the problem. Until I clicked on my "doneButton" to run the createClient () function and return to the client page to edit the newly created client, a click gesture will act to reject the keyboard.
import UIKit import CoreData import Foundation class NewClientTableViewController: UITableViewController, UINavigationControllerDelegate, UITextFieldDelegate { let managedObjectContext = (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext @IBOutlet weak var nameTxt: UITextField! @IBOutlet weak var ageTxt: UITextField! @IBOutlet weak var phoneTxt: UITextField! @IBOutlet weak var emailTxt: UITextField! @IBOutlet weak var heightTxt: UITextField! @IBOutlet weak var notesTxt: UITextView! var client: Client? = nil override func viewDidLoad() { super.viewDidLoad() if client != nil { nameTxt.text = client?.name ageTxt.text = client?.age heightTxt.text = client?.height phoneTxt.text = client?.phone emailTxt.text = client?.email notesTxt.text = client?.notes self.title = client?.name phoneTxt.delegate = self let tapGesture = UITapGestureRecognizer(target: self, action: Selector("hideKeyboard")) tapGesture.cancelsTouchesInView = true tableView.addGestureRecognizer(tapGesture) } } func hideKeyboard() { tableView.endEditing(true) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning()
source share