0

I am tried counting the number to make UIImage perfect size each time, so I am making the comic app, and I can upload without a set number to make perfect like that.

I try to import IMG in which UIImage from comicsCell (UITableViewCell) by the Storyboard used. here i am trying to research for almost 2 weeks and nothing to find a trick way to automatically UIImage Height.

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return Int(comicsCells.IMG.bounds.height)
        // error: Cannot find 'comicsCells' in scope
    }

Let me know if you find any code to allow me to import the image with automatic height itself.

Thank you!

CoffeeTableEspresso
  • 2,614
  • 1
  • 12
  • 30
Antonio Adrian Chavez
  • 1,016
  • 1
  • 7
  • 12

1 Answers1

0

You can try the automaticDimension like that:

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableView.automaticDimension
}

PS: Top and bottom constraints is required for this to work.

Check this post.

Gkonst
  • 26
  • 5
  • Nice one! But I don't like give me a lot of work to do top and below or do number like that. I have seen some comic app just import to app and it automatically prefect height when upload not matter height number like that. I was hard to think like that. – Antonio Adrian Chavez Nov 07 '20 at 07:30