如何在 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 高度。
最佳答案
试一试:
1.
这应该是您对 tableView
的约束:
2.
//declare a constraint outlet and connect it
IBOutlet NSLayoutConstraint *constraintGrayViewBottom;
3.
这是灰色 View 的底部约束,即:constraintGrayViewBottom
。
如图所示选择底部约束,然后在右侧单击并拖动引用导出连接到 viewController,并将其连接到 constraintGrayViewBottom
。
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/