0

I have a class A , subclass of UITableViewCell, and just linked its IBOutlet property titleLabel to UILabel in the storyboard. but seems I can not change the frame of titleLabel.

- (void)awakeFromNib
{
    [super awakeFromNib];
    self.titleLabel.frame = CGRectMake(10.f, 20.f, 100.f, 25.f);
}

and also execute the code in - (void)layoutSubviews , but not working.

Confusingly when tapped the Cell on the app running in device, the position changed, and I create the titleLabel using code, change the frame, then that's all right.

Could anyone help me..

shanegao
  • 3,562
  • 1
  • 18
  • 21

1 Answers1

1

Resolved this issue as follow :

First add constraints for the view, then connect the constraint properties (Leading, Trailing, Top, Bottom ...) with source files, created the @IBOutlet property variables.

Second modified the value of constrains in the - (void)updateConstraints

- (void)updateConstraints
{
    [super updateConstraints];
    self.titleLabelHeight.constant = 100.f;
    self.titleLabelLeading.constant = 20.f;
    //...
}
shanegao
  • 3,562
  • 1
  • 18
  • 21