I am working with autoLayout, I want to place a UIlabel on UITableViewCell, which should be always at the right of the cell and the center of right.
So here is what I want to achieve
So here you can see label named RC which I am talking about.
So here my cell height changes dynamically, so whatever be the text height I always want to be the center right.
2) Now as the cell height depends on the text of the label sentence. I want to make sure that if the cell has the default height and it will not decrease below it. It can increase to any height.
Select your label go to editor then select vertical center in container, also fix it using the trailing space from super view and set fit size to content and it should work. For dynamic tableViewCell height created using autolayout find the TUTORIAL. This will help you a lot.
Related
I'm trying to create a custom UITableViewCell with the goal that it should look and resize exactly the same way as the standard cell. The only difference is that my custom cell is using an editable UITextField instead of a UILabel.
It is working fine except for the case when dynamic type is set to smaller than default.
Here's the setup:
Here's how it looks in three different dynamic text sizes:
The one on the very right is the problem. Here my cell on the top is much smaller than the default cell with the "Login" label below it.
How can I make my cell have the exact same size as the default cell in all dynamic text sizes?
Wrap the textField in a simple view, let's call it wrapperView that has top, bottom, leading and trailing constraint to the contentView set to 0; then on your wrapperView set an height constraint that is greaterThanOrEqualTo a minimum value, i.e 44pt (which should be the default cell height)
I have created a tableview with dynamic cells. I have added a label in a cell.
The label is always placed in centre of the cell.
I don't want it to be dynamically placed when I adjust the height of the row.
I would like to place the label 20px under the top of the cell.
How can I do this?
You can set constraints like top,leading,trailing and fixed height to that label if you are using autolayout.
Put your label in cell with 20 pixel of distance from top and then set constraints or pin constraints as mentioned above.
Hope this will help :)
Use Auto Layouts in your StoryBoard. Like these
You have to setup all the constraints in the storyboard to make it work properly.
If you use autolayout, set constraint.
Select label and Drag to upper of label by pushing control.
When popup appears, push option key.
Click "Top Space to Container"
enter image description here
Select label and look into size inspector. Modify constant value of "Top Space To" constraint to 20.
enter image description here
If using Auto Layouts, give these 4 constraints, it will work.
Drop the label on custom cell where exactly you want, give top space, tailing and leading and also a fixed height.
In my app i have a UILabel and a UIImageView under each other. Both of them have a fixed width, but their height supposed to change.
I want the UILabel's height to change to fit the text it's holding and i want the UIImageView's height to change automatically to fill the width and keep it's aspect ratio.
My problem is that autolayout doesn't allow me to have both item's vertical content compression resistance priority to the same constant. Because of this one item will always oppress the other.
What i expect is the tableviewcell to change it's height dynamically to fit its content.
I do not want to modify anything from code.
You can do it in alot possible way like
1.) Using StackView here is a link to help http://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views
2.) You can select your UILabel and its superView than select aspectRatio , in a same way select your UIImageView and the superView than select aspectRatio.
It will help Thanks.
I have a UITableView below that has a custom uitableview cell. I am trying to get the two labels inside it do be 50% in width and have the left cell have right aligned text and the right cell to have left aligned. Any clue why this isnt working correctly below?
Use auto-layout, and set both the labels an equal width constraint, it should do the trick.
Edit:
Without auto-layout you can try something like that:
My Goal
I'm creating a custom UITableViewCell (MessageCell), and I'd wish to have my UITextView resizing both in width and height whenever the cell changes its size, while keeping some basic constraint like margins to the edges.
Note : I also change my cell's height in the heightForRowAtIndexPath method depending on the content which will be placed into UITextView.
What I tried
Here are all the constraints currently applied & the cell :
I tried :
With a UILabel.
To fix a Vertical Space from the bottom, thinking it would change the height to fit all the constraints.
To override Height with an User Constraint Height >= 43 (my initial height), but the purple-automatic Height is re-created again whenever I do this.
To find a solution on SO first, but didn't find a case like (even if the UITextView's height's resize with autolayout seems to be a frequent issue).
Plenty of combinations of various & random constraints until my fingers bleds.
How it render now
So...
If someone has any clue or guideline to achieve my goal, I'd appreciate!
I might add, I'm totally new to Autolayout & constraints. My reference : Ray Wenderlich's awesomeness
You need to get rid of that height constraint that the text view has. Make sure you have constraints to something above and below the text view (usually the top and bottom of the cell), and then you should be able to delete that height constraint.