gpt4 book ai didi

ios - 如何在 viewdidload 中以编程方式调整 TableView 的高度

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:16:48 25 4
gpt4 key购买 nike

如何在 viewdidload 中以编程方式调整我的 tableview 高度?实际上我在我的应用程序中有一个 View 我希望 View 将加载然后 uivew 将隐藏 ang tableview 高度将增加?怎么做到的?我在 viewdidload 中添加了这些行,但没有任何反应?

- (void)viewDidLoad {
[super viewDidLoad];
CGRect tableFrame = [tableListView frame];
tableFrame.size.height = 127;
[tableListView setFrame:tableFrame];
}

下面是我的屏幕截图我想隐藏那个 greycolourview 并想增加我的 tableview 高度。 enter image description here

screen shot

最佳答案

试一试:

1.

这应该是您对 tableView 的约束:

enter image description here


2.

//declare a constraint outlet and connect it
IBOutlet NSLayoutConstraint *constraintGrayViewBottom;

3.

这是灰色 View 的底部约束,即:constraintGrayViewBottom
如图所示选择底部约束,然后在右侧单击并拖动引用导出连接到 viewController,并将其连接到 constraintGrayViewBottom

enter image description here


4.

以处理约束变化为例:

-(void)viewDidAppear:(BOOL)animated {
constraintGrayViewBottom.constant = -60;

[UIView animateWithDuration:1
animations:^{
[self.view layoutIfNeeded];
}];
}

关于ios - 如何在 viewdidload 中以编程方式调整 TableView 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27173025/

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