Build off of default UITableViewCell Swift - ios

I'm trying to build a custom UITableViewCell where the custom title label is correctly aligned with a default UITableViewCell's title label. However, the labels are not correctly aligned as shown below. The custom cell was made in a xib file.

I believe you could increase the left margin of your label (Username) so that it will be aligned with others' labels.

Related

iOS Swift Multiline UILabel with StackView Inside UITableViewCell

I have three UILabels inside a UIStackView which is inside a UITableViewCell. All my labels have lines set to 0. Problem is labels sometimes gets disappeared or shows partial texts.
Things I have tried:
Embedded each label inside UIView and set Constraints to them so take full UIView size. In this case, StackView had both alignment and distribution set to fill.
StackView set alignment set to leading and UIVIews had same setup as the first try.
Tried without the StackView but still, Labels doesn't show full text or gets disappeared.
A sample Stackview setup I tried
Output I am getting:
As seen on the image, Arabic texts get disappeared (Shown with red notation). Some English texts are show partially. (Shown in yellow)
Other answers on StackOverflow I followed:
Multiline label in UIStackView
Multiline label in UIStackView
UIStackView and multi-line labels in a UITableViewCell
Multi Line Labels and an Image with UIStackView
Try 1: From an answer:
According to the suggestion of Talha, I made the following changes
But no luck. The output I got from the changes:
Set the label's constraint to (top, left, right, bottom , equal hight). Then you have to change equal height constraint value "greater than equal" from the attribute inspector. Now change the label attributes "line break=word wrap" , "lines=0"

Custom UITableViewCell that looks like the standard cell

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)

Custom UITableViewCell Leading Alignment to Right Detail Cell

I am using a UITableView with static UITableViewCells. I am using custom cells and also right detail cells. I would like to get the UILabel within the custom cells to align with the UILabel within the right detail cells.
I checked within Interface Builder, and it shows the UILabel in the right detail cell to have the x origin to be 15. Within the custom UITableViewCell, I set the UILabel to have the same starting x origin. This works great on iPhones, but when I load the app on an iPad, they aren't aligned properly. The UILabel within the right detail cells appear to have a starting x origin of about 18.
Is there something I can do to ensure the UILabels have the same leading alignment within Interface Builder, or do I need to programmatically set constraints depending on the type of device?
Unfortunately I don't think there's an easy way to make constraints based on Apple's pre-made cells. You'll probably have to go with just programming the constraints manually, or another option is to make your own implementation of a right detail cell and make the constraints the same as your other custom cell.

Stretch UILabel to full width of UICollectionViewCell

This sounds like a trivial thing to do, but for some reason I can't figure out how to get this work with AutoLayout.
I have a UICollectionViewCell with two subviews in Interface Builder
UICollectionViewCell
- UILabel
- UILabel
The UICollectionViewCell has a dynamic width height, and so I'd like to set the first UILabel's frame to be something like this using AutoLayout.
CGRectMake(5, 5, collectionViewCell width, collectionViewCell height-10);
However if I select UICollectionViewCell and UILabel, and then click the left-most icon to "Add new alignment constraints", then none of the options are available (e.g. Trailing Edges).
Those menu items were not enabled, because the two items you selected did not have a common superview.
Select UILabel without also selecting UICollectionViewCell.
Auto Layout already understands that the cell is the label's superview, and knows to pin the label's edges to the cell.
Update:
The 'Pin' tool is used for size, or spacing between items. In your
case, you want to set the space between your label and the cell.
The 'Align' tool is used for centering items, or lining items up by
an edge. For example, if you had two labels in your cell, you could
ensure that one label lined up with the other label's baseline.

Working with AutoLayout using UITableViewCell

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.

Resources