Why does my UITableView report itself as 600x600,

2019-07-17 07:06发布

问题:

My UITableView, when I po the frame in the debugger, reports its width and height as 600x600. I have it pinned to the sides of its view controller, so I don't understand why it would be reporting this.

The 600x600 is its dimensions within the Any x Any Storyboard grid, but like I said, it should be updating.

Is this a glitch?

回答1:

It will report 600x600 dimensions until its layout is complete. If you override viewDidLayoutSubviews method and put a breakpoint there:

- (void) viewDidLayoutSubviews
{
   [super viewDidLayoutSubviews];
   //
   // NSLog frame here
}

You will get proper frame size.