我试图调用一个函数,在heightForRowAtIndexPath
该函数中隐藏和显示该单元格内的视图,但我不情愿地创建了一个无限循环。请指出是什么问题以及我该如何解决。
作用于heightForRowAtIndexPath
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"indexrow = %ld \n pre = %d\n sel = %d \n",(long)[indexPath row],previousselectedcell,selectedcell);
if([indexPath row] == previousselectedcell){
return 60;
}
else if ([indexPath row] == selectedcell) {
NSLog(@"height toggle= %@",toggle);
[self ViewToggle:tableView IndexPath:indexPath Do:@"true"];
return 180;
}
else
{
return 60;
}
}
功能定义
-(void)ViewToggle:(UITableView *)tableView IndexPath:(id)myindexPath Do:Toggle{
InterestTableViewCell *cell = (InterestTableViewCell *) [tableView cellForRowAtIndexPath:myindexPath];
if([Toggle isEqualToString:@"true"]){
cell.ContainerView.hidden=NO;
}
else{
cell.ContainerView.hidden=YES;
}
}