Create tableview and design it in CustomTableCell Name,code,continent,population line etc. and got the values from web web services united states,usa,989898,north America etc. In CustomTableCell design it. my problem name should be a canada means code and continent want to hide and display population:979797 and height should be reduse. next mexico means want to display all values.china and afghanistan values should be code, continent hide. Population:要显示。如何提供帮助(我的疑问:在tableview单元格中创建一个标签,该标签将在所有单元格中显示如何在每个单元格中隐藏和显示)。想在heighforrow中的cellforrow中做什么。请在此处查看屏幕。
是的,这是可能的。您必须在方法中基于国家/地区名称应用条件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);
}
希望它能工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句