Constraints variable views such as TableView

Asked 2 years ago, Updated 2 years ago, 83 views

In order to accommodate AutoLayout, the height of the View changes depending on the content, such as TableView,
I want to restrict it, but I don't know how to restrict it.
Currently, it is at least 220px, so I have a [Great than or Equal 220px] restriction, but
An ininequality constraint ambiguity が warning appears.There is no problem with the operation.
How do I get rid of the warnings?

ios autolayout

2022-09-30 20:35

1 Answers

That's not the answer.
In this case,

The IUITableView is pasted on a storyboard or xib on top of another UIView.
IIUITableView is paired with a UITableViewController and is included in the top ContainerViews.

There are two possible cases.
 In , you can create an outlet that is a constraint but also a constraint as a UI part.Hold down Ctrl and drag it with your mouse.Then
IBOutlet NSLayoutConstraint* tableHeightConstraint;

You can make a declaration like this in the file's controller file.

For more information, see the NSLayoutConstraint Class Reference. It has a property called @property(getter=isActive)BOOL active and
You can control whether the constraint is enabled or disabled.

Therefore, if there are less than 5 cells in the ViewWillAppear of the ViewController source on this screen, enable constraint height 220 and if there are more than 5 cells, disable constraint or make it different
What do you think of course.
 Of course, the frame on the storyboard depends on how it is pasted.


2022-09-30 20:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.