如何在其他视图生成之前完成一个视图的约束

时间:2016-06-17 03:27:50

标签: ios objective-c constraints

现在,我将生成一个titleview,它的高度是tableHeaderView.so的变量。我需要在tableview生成之前确认titleview的hegiht

//titleView
JMProductTitleView *titleView = [[JMProductTitleView alloc]initWithFrame:CGRectMake(0, 0, JMDeviceWidth, 300)];
titleView.delegate = self;
JMProductDetailModel *model = [JMPorductDetailTool createProductDetailModel];
titleView.model = model;
_titleView = titleView;

//
UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, JMDeviceWidth, JMDeviceHeight) style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
tableView.tableHeaderView = titleView;
[self.view addSubview:tableView];
_tableView = tableView;

1 个答案:

答案 0 :(得分:1)

您可以尝试使用[self.view layoutIfNeeded]。它将强制视图布局所有约束。