UIview的Xcode 8返回高度= 1000和宽度= 1000(实际大小为(328,40))

Som*_*mmm 11 height width uiview

自从我安装Xcode 8后,我遇到了麻烦.我没有得到每个或任何UIView的正确值.

我也得到了UIView的约束警报.所以我更新它.但是视图返回1000作为宽度或高度.我试过或搜索了很多.但没有得到任何适当的解决方案.请帮助我.

sil*_*sky 14

如前所述这里,你应该打电话layoutIfNeeded对你的看法viewDidLoad:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.view layoutIfNeeded];

    // Now all your subviews are sized as you expect
}
Run Code Online (Sandbox Code Playgroud)

  • 它适用于swift - self.view.layoutIfNeeded() (2认同)