Why does the modal view of the view controller interrupt the automatic layout in my table view?

Project example: http://cl.ly/1o2K2m2r262q

I have UITableViewwith custom cells that are automatically calculated by height from Auto Layout. Custom cells have three labels, each of which is located with a vertical interval between each other and the type of content and is discarded on the left side.

It works great when entering data and loading.

However, when I fashionably present a view controller from a view controller containing a table view, I notice that it completely breaks the automatic layout when I return to the original view controller.

What can cause this? I populate the data into a simple array that acts like a model for a table view data source, and then it's just an automatic layout. This is such a simple project that I get confused where it would be useless.

Addendum: I appreciate rdelmar's answer, but I just can't believe that no application has been sent right now that uses this feature of iOS 8 dynamic cells without making terribly animated table views. That would be incredibly noticeable. Someone must have figured out a way to do this work, otherwise they would never have sent it.

+4
source share
4 answers

. . . , ( , , ).

MasterViewControllerDidLoad , ,

self.tableView.estimatedRowHeight = 120
self.tableView.rowHeight = UITableViewAutomaticDimension // you may not need this one, I think it might be the default now

, , ( ), , ( , ),

override func didMoveToSuperview() {
        self.layoutIfNeeded()
    }
+2

: , : → → :

  • " "
  • " "
  • " "

UITableView, :

override func awakeFromNib() {
    super.awakeFromNib()
    tableView.estimatedRowHeight = 200; // You need approximately calculate this value by yourself, used mostly for the scroll indicator displaying
    tableView.rowHeight = UITableViewAutomaticDimension;
}

https://dl.dropboxusercontent.com/u/48223929/LayoutingTest.zip

0

, . 44. tableView Storyboard :

Old tableView row height

tableView , , , , 200 :

Suggested tableView row height

, iOS 200, , , .

?

- - - iOS. iOS 8-10 iPhone, , , iOS / , - . , iOS , , . , .

0

- .

- , . 44, 200 , .

Storyboard

Also check the warnings in the storyboard file.

0
source

All Articles