Adam Adam - 4 months ago 22
iOS Question

How to hide keyboard while keeping cursor in swift

I am making a calculator and using my own keypad and i want there to be no keyboard that pops up when the textview is activated but i want the user to be able to move the cursor around. Any ideas are greatly appreciated.

Answer

you can change the inputView for the textfield to custom UIView. Something like below.

@IBOutlet weak var myTextField: UITextField!
let customView = UIView()

override func viewDidLoad() {
    super.viewDidLoad()

    myTextField.inputView = customView
}