In tableview cell, I have set cell title text alignment as center, It is worki
It is because of autolayout which you have not set properly. Did you solve your problem. Why do u really need the following
self.textLabel.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutConstraint *labelHCN = [NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.f constant:0];
[self.contentView addConstraint:labelHCN];
NSLayoutConstraint *labelVCN = [NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.f constant:0];
[self.contentView addConstraint:labelVCN];
I thing you have trouble because of this code. Can u try excluding it
You better declare about the text field as following
In BaseListCell.m
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
if (self) {
}
return self;
}
- (void)awakeFromNib {
self.textLabel.textColor =[UIColor grayColor]
self.textLabel.textAlignment = NSTextAlignmentCenter;
self.textLabel.font = [UIFont mediumFontWithSize:16.f];
}
First enable the Use Auto layout and Use Size Classes as below do that first in both table view and table view cell .and tell me your problem
If you want to place the text vew or label or etc in right of the table view then click on pin of it.
Then select constraint left,right,top and only height.
click on add 4 constraints
you can check this too:
iOS - Custom table cell not full width of UITableView