1

I have a TableViewController, which contains 2 ImageView, some UILabel.I set up the contains like this: enter image description here

everything seems fine. and for the last UILabel, I want to show all the content based on the length of the content, which means I need the TableViewCell to adjust its height dynamically. I used this code to achieve this function:

override func viewDidLoad() {
    super.viewDidLoad()

    self.tableView.estimatedRowHeight = 70
    self.tableView.rowHeight = UITableViewAutomaticDimension

}

It works. However, when I scroll the TableView, somethings strange happen, the screen flashed, and you can not scroll back to the top, something like this: enter image description here

sorry I don't know how to show this error properly, it's flashing, and you cannot scroll the screen, you can only choose the back button.

I guess this maybe something wrong with the AutoLayout constrains, or the estimatedRowHeight, here I just set it to 70 based on the tutorial I learnt, I don't know how to set this value properly.

vitr
  • 6,766
  • 8
  • 30
  • 50
Leo Guo
  • 185
  • 3
  • 16
  • Problem solved, I checked this [link](http://stackoverflow.com/questions/35437610/reloading-table-causes-flickering), and I have the same issue, since every time I scroll the table view, it downloads images, thats why it flash. – Leo Guo Aug 22 '16 at 07:40

1 Answers1

0

Your UI's setup looks alright. There should be another problem regarding datasource i think. In your both imageview and your labels, how you setting respective value is also affect. For example if you getting data from server then you should cache the images for reuse because tableview deque the cells.

If you are getting images from server then you should cache the images. to do that you can use great library SDWebImage .

So check twice that what causes problem. According to me constraints and UI's setup is fine!

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • Thanks for checking my problem, yes, something went wrong when I download data from the Internet, I fixed it, and now it works fine. Thanks anyway – Leo Guo Aug 22 '16 at 08:53