Xcode 如何在Swift中使用按钮隐藏静态UITableViewCell
嗨,我有一个静态单元格的表格视图。我想用一个按钮隐藏特定的。我必须根据iphone的当前时间隐藏它们,所以我为它们创建了UITableViewCell插座。单击按钮时如何隐藏单元格?提前谢谢。我知道你想做什么。如果要隐藏操作,则需要控制静态tableView。 不要忘记在操作中重新加载tableviewXcode 如何在Swift中使用按钮隐藏静态UITableViewCell,xcode,uitableview,Xcode,Uitableview,嗨,我有一个静态单元格的表格视图。我想用一个按钮隐藏特定的。我必须根据iphone的当前时间隐藏它们,所以我为它们创建了UITableViewCell插座。单击按钮时如何隐藏单元格?提前谢谢。我知道你想做什么。如果要隐藏操作,则需要控制静态tableView。 不要忘记在操作中重新加载tableview [self.tableView reloadData]; -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPat
[self.tableView reloadData];
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
cell.hidden=YES;
return 0;
}else{
UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
cell.hidden=NO;
return [super tableView:tableView heightForRowAtIndexPath:indexPath];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
return cell;
}
这不是目标C吗?我需要用Swift编码。顺便说一句,我也可以用一个UITAbleViewCell插座隐藏一个单元格。但它不会消失,只是它所包含的东西消失了。我想我需要将单元格高度设置为0。