You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, @smileyborg, I'm so excited to use PureLayout when lost in large numbers of constraints added for views. However, when I tried to put the same code in a custom UIView enbedded with a tableview, it shows lots of warnings in the console.
Here's the warnings.
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7fa5e1f5a300 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x7fa5e1f51930(0)]>",
"<NSLayoutConstraint:0x7fa5e1db41d0 UILabel:0x7fa5e1f52600'The correct API to use is...'.trailing == UITableViewCellContentView:0x7fa5e1f51930.trailing - 15>",
"<NSLayoutConstraint:0x7fa5e1d95df0 H:|-(15)-[UILabel:0x7fa5e1f52600'The correct API to use is...'] (Names: '|':UITableViewCellContentView:0x7fa5e1f51930 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fa5e1db41d0 UILabel:0x7fa5e1f52600'The correct API to use is...'.trailing == UITableViewCellContentView:0x7fa5e1f51930.trailing - 15>
I wonder what on earth the difference is between setting constraints in a tableview and in a tableviewcontroller. As fresh to autolayout, what should I pay attention to when handling these kinds of problems? Could you give me some suggestions?
Hope to hear from you. Thanks in advance.
The text was updated successfully, but these errors were encountered:
@Lilacxyz It's hard to say exactly why you're seeing this constraint exception, but basically the problem here is that the width of the table view cell's contentView is 0, and your constraints require at least 30 width (15 leading + 15 trailing).
So the issue is probably not with your constraints, but with how the cell is getting created/etc. You'll probably need to share a sample project if you need more help figuring out why this is happening.
You're exactly right! When I logged in heightForRowAtIndexPath, I found the width of cell's contentview is 0. I also upload my project here.[https://github.com/Lilacxyz/AutolayoutDemo]
Maybe I should learn more clearly what the differences between UITableViewController and UITableView is? Or UIViewController and UIView?
Hi @CaliosD. I got a related problem, but in my case I think the size of the cell was 320 x 44 by default, which wasn't enough to contain my views (I had one view of height 60 so I needed 60 + margins minimum). I fixed that problem with this solution. I hope it helps.
Hi, @smileyborg, I'm so excited to use PureLayout when lost in large numbers of constraints added for views. However, when I tried to put the same code in a custom UIView enbedded with a tableview, it shows lots of warnings in the console.
Here's the warnings.
I wonder what on earth the difference is between setting constraints in a tableview and in a tableviewcontroller. As fresh to autolayout, what should I pay attention to when handling these kinds of problems? Could you give me some suggestions?
Hope to hear from you. Thanks in advance.
The text was updated successfully, but these errors were encountered: