Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/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
UITableViewCellSeparator从堆栈弹出后重新出现的问题_Uitableview_Ios7_Uinavigationcontroller - Fatal编程技术网

UITableViewCellSeparator从堆栈弹出后重新出现的问题

UITableViewCellSeparator从堆栈弹出后重新出现的问题,uitableview,ios7,uinavigationcontroller,Uitableview,Ios7,Uinavigationcontroller,我有一个将动态数据加载到tableview中的应用程序。当只有一个项目(因此只有一个单元格)时。为确保UITableViewCellSeparator未显示此项,我使用以下代码: - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { // This will create a "invisible" footer return 0.01f; }

我有一个将动态数据加载到tableview中的应用程序。当只有一个项目(因此只有一个单元格)时。为确保UITableViewCellSeparator未显示此项,我使用以下代码:

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {

    // This will create a "invisible" footer
    return 0.01f;

}
这正如预期的那样工作,下面是我的手机的外观:

正如您所看到的那样,它的工作原理与预期相同,并且没有单元格分隔符

当我选择单元格并显示我的详细信息视图,然后单击“上一步”按钮时,由于某种原因,该单元格会添加一个分隔符。以下是我返回堆栈后单元格的外观:

您会注意到分隔符现在比标准分隔符宽。如果我的tableview中有多个单元格,则tableview中的最后一个单元格的行为方式相同

当我删除上面的方法时,这个问题已经解决了,但是现在我的tableview有很多额外的空单元格分隔符。有更好的解决办法吗

以下是我的cellForRowAtIndexPath方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"searchCell";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
    }

    // Configure the cell...

    cell.backgroundColor = [UIColor PFBlack];

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    cell.textLabel.font = [MuseoSans font500WithSize:16.0f];
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.text = @"Current Location";


    return cell;

}

知道是什么导致了这个问题吗?还是我做错了什么?谢谢

这将删除额外的单元格分隔符:

tableVie.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

您可以通过以下两种方式完成此操作

首先是

[self.tbl setSeparatorStyle:UITableViewCellSeparatorStyleNone];
第二个是

[self.tbl setSeparatorStyle:UITableViewCellSeparatorStyleNone];
将tableview属性从“默认”更改为

至“无”

这将完全拆下分离器。我仍然希望它们出现在tableview中,我只是不希望出现多余的分隔符。如果我有两个项目,分隔符将显示为有5个单元格。这确实会移除分隔符,但当我将某个项目推到堆栈上,然后将其弹回去时,底部单元格中较大/较宽的分隔符仍会重新出现。您找到解决此问题的方法了吗?