Sunday, April 19, 2026
HomeiOS Developmentios - How can I sift textual content from one textview to...

ios – How can I sift textual content from one textview to different whereas enhancing

[ad_1]

I’ve textview inside tableView cells and I am creating newTextview when a textview exceeds most variety of strains and shifting to new textview.I drawback is I am unable to shift the textual content to earlier or subsequent textview after I delete or add textual content to the prevailing textview. This is a clip for higher rationalization

This is the code for TextView Delegate:

        func textView(_ textView: UITextView, shouldChangeTextIn vary: NSRange, replacementText textual content: String) -> Bool {
   
    return addNewTextView(textView: textView)}

  func addNewTextView(textView:UITextView)->Bool{
    let numLines = Int((textView.bounds.height-16) / textView.font!.lineHeight)
    let currLines = textView.lineCount
    print("These are complete variety of strains (numLines)")
    print("These are curr strains (currLines)")
    if currLines>numLines {
            pageCount += 1
            tableView.beginUpdates()
            tableView.insertRows(at: [IndexPath(row: textView.tag+1, section: 0)], with: .automated)
            tableView.endUpdates()
            moveToNextTextView(textView: textView)
        return false
        }
    return true
    }
}



personal func moveToNextTextView(textView:UITextView){
    let cell = textView.superview?.superview?.superview as! EditorTableViewCell
    
    self.tableView.scrollToRow(at: IndexPath(row: textView.tag+1, part: 0), at: .prime, animated: true)
    cell.editorTextView.becomeFirstResponder()
    self.tableView.layoutIfNeeded()
    self.tableView.reloadData()
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments