【发布时间】:2014-02-05 00:44:18
【问题描述】:
我正在研究 xcode 5 和 ios7,有一个包含 7 个部分的表格视图,我必须根据条件显示/隐藏三个部分,为此我已将该部分行的高度设置为 0,它运行良好在 ios7 上,但当我在 ios6 上运行时,也会查看高度为 0 的行。请让我知道我应该怎么做才能在 ios6 中防止这种情况发生。
IOS7 视图
在 ios6 中,显示在 ios 7 中隐藏的 paypal 行。选择否时,我不必显示此内容。
代码:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section==3 && !isadvisor)
{ return 0;}
if(indexPath.section==4 && !isadvisor)
{return 0;}
if(indexPath.section==5 && !isadvisor)
{ return 0;}
if (indexPath.section==0 && indexPath.row==0) {
return 110;
}
if (indexPath.section==3 && indexPath.row==2) {
return 125;
}
return 40;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{ return 7;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section==0) return 8;
else if(section==1) return [arr3 count]+1;
else if(section==2) return 1;
else if(section==3) return 5;
else if(section==4) return [arr1 count]+1;
else if(section==5) return [arr2 count]+1;
else if(section==6) return 1;
else return 0;
return 0;
}
请帮助我应该如何解决这个问题。 任何建议将不胜感激。 提前致谢。
【问题讨论】:
-
您是否将元素放在高度为 0 的行上,高度不是基于单元格的高度?也许单元格的高度为零,但不是它们上面的元素。
-
@TotumusMaximus 是的,元素高度不是 0,但它在 io7 中正常工作,但在 ios6 上没有。
标签: iphone ios6 uitableview ios7 xcode5