show keyboard on tap

I was trying to follow developer app guide to create a very simple app.


I have a textfield and when I'm finished typing I will click on DONE button which will result in hiding the keyboard. my problem is that after the first time this happens the keyboard won't show again no matter how many times I tap/click on the textfield


here is my code

:



import UIKit

class ViewController: UIViewController, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

/

@IBOutlet weak var nameTextField: UITextField!

@IBOutlet weak var mealNameLabel: UILabel!

@IBOutlet weak var photoImageView: UIImageView!

override func viewDidLoad() {

super.viewDidLoad()

nameTextField.delegate = self

}

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

/

textField.resignFirstResponder()

return true

}

func textFieldDidEndEditing(_ textField: UITextField) {

mealNameLabel.text = textField.text

}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {

/

dismiss(animated: true, completion: nil)

}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

/

guard let selectedImage = info[UIImagePickerControllerOriginalImage] as? UIImage else {

fatalError("Expected a dictionary containing an image, but was provided the following: \(info) ")

}

photoImageView.image = selectedImage

dismiss(animated: true, completion: nil)

}

/

@IBAction func selectImageFromPhotoLibrary(_ sender: UITapGestureRecognizer) {

/

nameTextField.resignFirstResponder()

/

let imagePickerController = UIImagePickerController()

/

imagePickerController.sourceType = .photoLibrary

/

imagePickerController.delegate = self

present(imagePickerController, animated: true, completion: nil)

}

@IBAction func setDefaultLabelText(_ sender: UIButton) {

mealNameLabel.text = "Default Text"

}

}

Replies

>create a very simple app.


On what platform?

I had a similar issue. I do not know how it is solved, but I can tell you how I avoided this problem.


In the first case, you can use your physical keyboard. Or you can press two Command + K keys and then the keyboard in the app should appear.


And yet, I noticed that this problem appears in different apps.