Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 删除UITableViewCell的最后一个分隔符_Ios_Iphone_Objective C_Uitableview - Fatal编程技术网

Ios 删除UITableViewCell的最后一个分隔符

Ios 删除UITableViewCell的最后一个分隔符,ios,iphone,objective-c,uitableview,Ios,Iphone,Objective C,Uitableview,目前我有一个UITableView。我想删除最后一个单元格的最后一个分隔符 我是这样做的: UIView *footerN = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _tblStateGaisou.frame.size.width, 10)]; [footerN setBackgroundColor:[UIColor clearColor]]; tblStateNaisou.tableFooterView = footerN;

目前我有一个
UITableView
。我想删除最后一个单元格的最后一个分隔符

我是这样做的:

 UIView *footerN = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _tblStateGaisou.frame.size.width, 10)];

 [footerN setBackgroundColor:[UIColor clearColor]];

 tblStateNaisou.tableFooterView = footerN;
这只在iOS 7上起作用,在iOS 6上什么也没发生

有人知道如何解决这些问题吗


非常感谢您的帮助。

显示的分隔符数量由tableview本身决定。如果你想移除一个单独的分隔符,你会很挣扎

一个选项是完全移除分隔符,并在每个单元格的底部包含您自己的分隔符,忽略任何您不想看到的分隔符。

对于iOS 7.1

  if(indexPath.row == (arrayWithData.count - 1)) 
     {
        NSArray *subViews = [[[cell subviews] lastObject] subviews];
        for (UIView *view in subViews)
            {
               if([NSStringFromClass(view.class) isEqualToString:@"_UITableViewCellSeparatorView"]) {
                    [view removeFromSuperview];
                }
            }
        }
在iOS 7.0中,如果表视图节的页脚高度非零,则不会在该节的最后一行放置分隔符,因此只需将空视图设置为所需节的页脚,即可实现目标。这对我很有用

奇怪的是,如果使用tableView:heightforfootensection:将同一页脚视图的高度设置为零,则会失去效果,最后一个分隔符会重新出现。确保返回非零高度(例如“返回1”)


不确定这是否适用于iOS 6。不过,这与您的方法略有不同(节页脚与表页脚)。

这只适用于iOS 7,这就是问题所在。我在iOS 6上找不到这样做的方法。唯一的解决办法是像你说的那样愚蠢的方式:(刚刚注意到最后一个分隔符在单元格被选中或重新绘制时被绘制。奇怪的行为。
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{        
    return [[UIView alloc] initWithFrame:CGRectZero];
}