I have a UILabel in a UITableView cell.
To adjust the height of the cell depending on the height of the mark, this is normal, it works great.
But I need to add one more restriction. I need to display a UILabel with a typewriter effect (letter by letter).
My extension for the effect works well:
extension UILabel{ func setTextWithTypeAnimation(id:String, typedText: String, pauseCharacterArray: [Int:Double], characterInterval: TimeInterval = 0.06 ) { text = "" let group = DispatchGroup() group.enter() DispatchQueue.global(qos: .userInteractive).async { for (index, character) in typedText.characters.enumerated() { DispatchQueue.main.async { self.text = self.text! + String(character) } Thread.sleep(forTimeInterval: characterInterval) } group.leave() } group.notify(queue: .main) {
I tried calling this function in my configureCell foundation:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "ParagraphTableViewCell", for: indexPath) as! ParagraphTableViewCell cell.delegate = self self.configureCell(cell: cell, atIndexPath: indexPath) return cell } func configureCell(cell: ParagraphTableViewCell, atIndexPath indexPath: IndexPath) { let paragraph = paragraphArray[indexPath.row] as! Paragraph let pauseCharactersArray:[Int:Double] = [1:0, 6:0] cell.dialogueLabel.setTextWithTypeAnimation(id:"intro", typedText: "lorem ipsum", pauseCharacterArray: pauseCharactersArray) }
But the label does not appear. I think this is because the height of the label in the cell is 0, and it never gets updated.
I don’t know how to adjust the height of the cell live (every time the symbol is displayed)
EDIT
I am using autolayout
EDIT 2
The typewriter effect works in a simple UILabel without a UITableView:

Cell installed in xib:

When I start, UILabel does not appear:
