自动布局遇到的问题

我在UIViewContorller里的代码如下:

  • (void)viewDidLoad
    {
    [super viewDidLoad];
    [self.view addSubview:self.myTableView];

    [self layoutSubViewConstraints];
    }

  • (void)layoutSubViewConstraints
    {
    [self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.view.mas_top);
    make.left.equalTo(self.view.mas_left);
    make.right.equalTo(self.view.mas_right);
    make.bottom.equalTo(self.view.mas_bottom);
    }];
    }

运行后,报错:
2015-07-13 17:21:17.944 DirectorySpecification[3497:60b] *** Assertion failure in -[UITableView layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2903.23/UIView.m:8540
2015-07-13 17:21:17.946 DirectorySpecification[3497:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.'
*** First throw call stack:
(0x3013ef4b 0x3a57f6af 0x3013ee25 0x30ae6fe3 0x328b1e63 0x32538c6b 0x3253447b 0x3253430d 0x32533d1f 0x32533b2f 0x3252d85d 0x3010a1cd 0x30107b71 0x30107eb3 0x30072c27 0x30072a0b 0x34d99283 0x32916049 0xa5ce9 0x3aa87ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

不知道是因为什么原因导致。

回复
阅读 2.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏