Ever since I switched to Xcode 7.3 my life has become a living hell as Xcode started showing autolayout constraint issues in my layouts which were working fine in Xcode 7.2 and even after searching a lot I couldn't find a solution. Here's the problem...
I am trying to create a dynamic sizing cell having an UIImageView of certain aspect ratio(6:5). Below the image is a 1px height UIView that show as a separator(I cannot use the default separator for some reason so this is a must). Here are the constraints.
I assume that with these constraints the height of the cell can be calculated dynamically whenever the cell is shown. This all is very simple and works as expected if built using Xcode 7.2 but Xcode 7.3 shows warning at runtime.
Most of the time the views are shown perfectly but in few cases, because constraints are broken at runtime, views are laid out of their place. This is more of a general problem and is happening with almost all of my UITableViewCells. This particular example is the simplest of them all. Anyone with decent know how of autolayout cannot make a mistake in setting correct constraints...so is there anything wrong with my constraints or is there anything wrong with Xcode, and more importantly how to solve this issue? Any help is much appreciated.
Add constraint like this on your imageview
and separator view
Ex. Add 4 constraint on separator view
and add 5 constraint on imageview
you can change priority after adding aspect ratio constraint from size inspector
after this add this code in viewDidLoad Method
self.table.estimatedRowHeight = 304.0f;
self.table.rowHeight = UITableViewAutomaticDimension;
Now all error gone
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.