Now this isn't a issue unique to Eureka, but perhaps there should be a default or an easy way to toggle this behavior for right-aligned text fields? It's definitely off-putting (to me) when typing.
I'm doing this which works for now (in reality should put normal spaces back when finished editing). Is there a better/cleaner way?
class MyViewController: FormViewController {
func replaceNormalSpacesWithNonBreakingSpaces(textField : UITextField) {
textField.text = textField.text?.stringByReplacingOccurrencesOfString(" ", withString: "\u{00a0}")
}
override func viewDidLoad() {
super.viewDidLoad()
form +++ Section("MySection")
<<< TextRow("title") {
$0.title = "Title"
$0.placeholder = "Title"
}.cellSetup {cell, row in
cell.textField.addTarget(self, action: #selector(MyViewController.replaceNormalSpacesWithNonBreakingSpaces), forControlEvents: .EditingChanged)
}
...
Thanks for the workaround, @heptal. I ended up doing the following to get the desired behavior for all my UITextFields:
// Configure text rows to make spaces visible on edit.
TextRow.defaultCellSetup = { cell, row in
cell.textField.addTarget(self, action: #selector(FormHelper.replaceNormalSpacesWithNonBreakingSpaces(_:)), forControlEvents: .EditingChanged)
cell.textField.addTarget(self, action: #selector(FormHelper.replaceNonBreakingSpacesWithNormalSpaces(_:)), forControlEvents: .EditingDidEnd)
}
Maybe that's as close to a built-in way as it gets?
Yep, would also appreciate an built-in solution for that. @heptal Thanks for the workaround!
@heptal nice workaround.
Thanks guys for this workaround - here's an updated version for Swift3.
Call EurekaWhitespaceWorkaround.configureTextCells() to use it.
https://gist.github.com/hannesoid/ed78904e33a362889d2bd38f2f09ec3b
This seems to be a iOS issue so we will not add any workaround in Eureka. Everyone facing the issue can easily add the workaround.
Regards
@lognaturel : can you please show FormHelper class ? Thank you
Most helpful comment
Thanks for the workaround, @heptal. I ended up doing the following to get the desired behavior for all my UITextFields:
Maybe that's as close to a built-in way as it gets?