First I show my cell
, my label has several constaints
:
In my - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
method.
I get the label
's constrains :
NSArray *cons = (((NoticeAnnouncementCell*)cell).mainTitle).constraints;
but I get a empty array.
You should first create an instance of cell and then access the constraint of label as below,
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell1 = (UITableViewCell*) [tableView cellForRowAtIndexPath:indexPath];
UILabel *label = (UILabel*) [cell viewWithTag:10];
NSArray *arrayOfLableConstraint = [label constraints];
}
By this you will get constraint only set to the label itself like width and height or any alignment constraint, to get all the constraint you should access the cell's constraint, don't worry about how to find labels constraint only out of other views, you can do that easily by just setting identifier for the constraints you set for the label.
You can set the identifier to the constraint by simply selecting the constraint individually and set the identifier from size inspector as show below,
Hope that helps you...