Eureka: Automatically assign first responder when view is displayed

Created on 7 Oct 2015  路  6Comments  路  Source: xmartlabs/Eureka

Is it possible to automatically assign the first responder when the form is created/displayed? For example, the first enabled input should open the keyboard and be open to input from the user.

I'm coming across from XLForm (which I just found out was also created by you guys, great work!) which has the assignFirstResponderOnShow property.

Most helpful comment

I guess now it's become row.cell.textField.becomeFirstResponder()?

It took me a while to find this.

All 6 comments

@dwightwatson We will not add this functionality to Eureka.

However you can easily set the first responder by...

public func viewDidAppear(animated: Bool) {
         super.viewDidAppear(animated)
         let row: BaseRow! = form.rowByTag("yourRowTag") // you can also hold a strong reference to the row
         row.cell.cellBecomeFirstResponder()
}

Awesome, thanks for that!

Out of curiousity, is there a reason that feature won't come to Eureka?

@dwightwatson
Is not as used as we initially thought and at the same time is pretty easy to get it work.
More features means more to maintain ;)

I guess now it's become row.cell.textField.becomeFirstResponder()?

It took me a while to find this.

If you're using a cell that uses something other than a text field as its input, cellBecomeFirstResponder() is probably still the way to go. I couldn't get becomeFirstResponder() to work for a DateTimeRow.

How to call cellBecomeFirstResponder for DateTimeRow ?

@raudabaugh any solution?

Was this page helpful?
0 / 5 - 0 ratings