Search code examples
iosswifteureka-forms

How to make first text input become first responder and show keyboard with Eureka forms?


I am using the Eureka forms swift library here: Eureka forms

I would like to have my first row of the input form become the first responder every time the view appears. I tried adding a .cellUpdate callback which is fired everytime the view appears, and doing a cell.becomeFirstResponder() but this did not work. Could someone with experience in this library please help? Thanks.


Solution

  • Try this

    import UIKit
    import Eureka
    
    class ViewController3: FormViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            form +++ Section("Custom cells")
                <<< TextRow("TextRow"){_ in
            }
        }
    
        override func viewWillAppear(animated: Bool) {
            super.viewWillAppear(animated)
            let row = self.form.rowByTag("TextRow") as! TextRow
            row.cell.textField.becomeFirstResponder()
        }
    }
    

    I hope this helps you