UItableview 每个单元格标签要隐藏和高度应该改变

UItableview each cell label want to hide and height should be change

创建表格视图并在 CustomTableCell 中设计它 名称、代码、大陆、人口 行等,并从 Web 网络服务中获取值 美国,美国, 989898,北美等。在CustomTableCell中设计。我的问题名称应该是加拿大意味着 codecontinent 想要隐藏和显示 population:979797 和高度应该减少。接下来 mexico 表示要显示所有值。chinaafghanistan 值应为 code, continent 隐藏。 人口:想展示。怎么可能有帮助。(我的疑问:在 tableview 单元格中创建一个标签,它显示在所有单元格中如何隐藏和显示在每个单元格中)。帮助我。 heighforrow 中的 cellforrow 想要做什么。请看屏幕 here.than 前进。

是的,possible.You 必须在方法 cellForRowAtIndexPath 中应用基于国家名称的条件。 像这样

if(countryName isEqualToString @"Canada"){
     countryInfoLabel.numberofLines=0;
     countryInfoLabel.text=[NSString stringWithFormat:@"Population:%@",populationFromService]];
}

根据国家名称在标签countryInfoLabel中插入信息并相应显示。使用 \n 移动到 countryInfoLabel.

中的下一行

要动态更改单元格的高度,请使用 heightForRowAtIndexPath 使用以下代码

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   return (countryName.frame.origin.height+countryInfoLabel.frame.origin.height);
}

希望它能奏效。