0

So UILabel isn't giving me the correct value for its frame size for some reason.

First I do the following to create a UILabel

UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 15, 10)];

And then I try to access and print its width, which should be 15:

int width = (int)myLabel.frame.size.width;
NSLog(@"LABEL FRAME WIDTH: %d", width);

However, the value that gets printed out is 256. I have no idea why it is behaving like this.

4

1 回答 1

1

我认为您正在使用自动布局。检查一次没有自动布局选项可能会得到正确的值。

于 2013-07-03T06:25:57.307 回答