相关疑难解决方法(0)

设置UIView的layoutMargins不起作用

UIViewControllerUIViewUITableView

UIView
|-UITableView
Run Code Online (Sandbox Code Playgroud)

我正在尝试设置这样的边距:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.layoutMargins = UIEdgeInsetsMake(30, 30, 30, 30);
    self.tableView.preservesSuperviewLayoutMargins = YES;
    [self.view layoutIfNeeded];
}
Run Code Online (Sandbox Code Playgroud)

但是这个观点没有发生任何事情.

以下是InterfaceBuilder的约束

(lldb) po self.view.constraints
<__NSArrayM 0x786ab6e0>(
<NSLayoutConstraint:0x7896e940 UIView:0x7896e470.trailingMargin == UITableView:0x79b51a00.trailing - 16>,
<NSLayoutConstraint:0x7896e970 UITableView:0x79b51a00.leading == UIView:0x7896e470.leadingMargin - 16>,
<NSLayoutConstraint:0x7896e9a0 V:[_UILayoutGuide:0x7896e510]-(0)-[UITableView:0x79b51a00]>,
<NSLayoutConstraint:0x7896e9d0 V:[UITableView:0x79b51a00]-(0)-[_UILayoutGuide:0x7896e600]>,
<_UILayoutSupportConstraint:0x7896c7d0 V:[_UILayoutGuide:0x7896e510(0)]>,
<_UILayoutSupportConstraint:0x7896c2b0 V:|-(0)-[_UILayoutGuide:0x7896e510]   (Names: '|':UIView:0x7896e470 )>,
<_UILayoutSupportConstraint:0x7896cbf0 V:[_UILayoutGuide:0x7896e600(0)]>,
<_UILayoutSupportConstraint:0x7896ea00 _UILayoutGuide:0x7896e600.bottom == UIView:0x7896e470.bottom>
)
Run Code Online (Sandbox Code Playgroud)

结果没有看到任何边缘,没有任何改变....我正在发布什么?

iOS 8

objective-c uitableview ios autolayout ios8

17
推荐指数
2
解决办法
2万
查看次数

标签 统计

autolayout ×1

ios ×1

ios8 ×1

objective-c ×1

uitableview ×1