In my case to calculate a UILabel frame.origin.x to make it on the right side with code below:
writerNameLabel.frame = CGRectMake(cell.frame.size.width - writerNameLabel.frame.size.width - 80.......)
NSLog(@" writerNameLabel frame width: %f",writerNameLabel.frame.size.width);
NSLog(@" cell frame width: %f",cell.frame.size.width);
NSLog(@" cell - writerNameLabel frame width: %f",cell.frame.size.width - writerNameLabel.frame.size.width);
NSLog(@" writerNameLabel frame x: %f",writerNameLabel.frame.origin.x);
2012-08-17 14:43:36.895 writerNameLabel frame width: 38.000000
2012-08-17 14:43:36.899 cell frame width: 320.000000
2012-08-17 14:43:36.902 cell - writerNameLabel frame width: 282.000000
2012-08-17 14:43:36.904 writerNameLabel frame x: 240.000000
----
2012-08-17 14:43:36.924 writerNameLabel frame width: 102.000000
2012-08-17 14:43:36.928 cell frame width: 320.000000
2012-08-17 14:43:36.931 cell - writerNameLabel frame width: 218.000000
2012-08-17 14:43:36.934 writerNameLabel frame x: 240.000000
The problem is that this
cell.frame.size.width – writerNameLabel.frame.size.width
part in my calculation doesn’t work, it only return the value of
cell.frame.size.width – 80
, why? Did I do anything wrong?
Please advise. Thanks.
Because the value of writerNameLabel.frame.size.width is 0 at that time.