gpt4 book ai didi

ios - 如何在其他 View 生成之前完成一个 View 约束

转载 作者:行者123 更新时间:2023-11-29 00:53:25 25 4
gpt4 key购买 nike

现在,我要生成一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com