Jimmy Ng Jimmy Ng - 10 days ago 7
iOS Question

How can I finished one view's constrains before other view generate

Now, I am going to generate a titleview that its height is variable for the tableHeaderView.so i need to confirm the titleview's hegiht before the tableview generate

//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;

Answer

You can try using [self.view layoutIfNeeded]. It will force the view to layout all the constraints.