现在,我要生成一个 titleview,它的高度对于 tableHeaderView 是可变的。所以我需要在生成 tableview 之前确认 titleview 的高度
//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;
最佳答案
您可以尝试使用[self.view layoutIfNeeded]。它将强制 View 布局所有约束。
关于ios - 如何在其他 View 生成之前完成一个 View 约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37872636/