Search code examples
swifteureka-forms

Eureka form, TextAreaRow scroll to bottom


Can I configure a TextAreaRow of an Eureka form to scroll to bottom? I am appending text to the TextAreaRow and would like to show the newly appended text.


Solution

  • TextAreaRow in Eureka is essentially an UITextView

    You can simply use UITextView's scrollRangeToVisible(_ range: NSRange) function in its cell setup and onchange blocks.

    So here's an example how you can use it.

    <<< TextAreaRow("") { row in
            //Row setup
    
        }.cellSetup({ (cell, row) in
             cell.textView.scrollRangeToVisible(NSMakeRange(cell.textView.text.characters.count - 1, 1))
        }).onChange({ (row) in
             //Your Change logic
    
             row.cell.textView.scrollRangeToVisible(NSMakeRange(row.cell.textView.text.characters.count - 1, 1))
        })