我的 ViewController 在初始加载时看起来像这样:
我的代码是:
- (IBAction)show:(id)sender {
[self change];
[tableView reloadData];
}
- (IBAction)close:(id)sender {
[self change];
[tableView reloadData];
}
-(void)change{
//assigning initial bounds to frame-1
CGRect frame1=CGRectMake(0, _pastProcessTV.frame.origin.y, self.view.bounds.size.width, self.pastProcessTV.bounds.size.height);
//assigning new bounds to frame-2
CGRect frame2=CGRectMake(0, **CGFloat y**,self.view.bounds.size.width,***CGFloat height***);
if (_showFullButton.isTouchInside) {
tableView.frame = frame2;
}
else{
tableview.frame = frame1;
}
}
我尝试了不同的方法。它不起作用。谁能帮我提供 Y 坐标和宽度
最佳答案
当你使用自动布局时,你必须使用 tableview 的 topconstraint 导出,当你想扩展它时,将其值设置为 0
所以它会按预期工作
如果您使用的是 iOS 7
[self.view layoutIfNeeded]
是必须的
关于ios - 点击时更改 TableView 高度(在 xib 中使用自动布局),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35746142/