uitableview - 从堆栈弹出后重新出现 UITableViewCellSeperator 的问题

标签 uitableview ios7 uinavigationcontroller

我有一个将动态数据加载到 TableView 中的应用程序。当只有一项时(因此只有一个单元格)。为了确保 UITableViewCellSeperator 不会针对这一项显示,我使用以下代码:

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

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

}

这按预期工作,这是我的单元格的样子:

Cell with no issue

正如您所看到的,这按预期工作,并且没有单元格分隔符。

当我选择单元格并显示详细 View ,然后单击后退按钮时,单元格由于某种原因添加了分隔符。这是我导航回堆栈后单元格的样子:

Cell with issue

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

当我删除上述方法时,问题得到解决,但现在我的表格 View 有大量用于空单元格的额外分隔符。有更好的解决方案吗?

这是我的 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];

source

关于uitableview - 从堆栈弹出后重新出现 UITableViewCellSeperator 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21273709/

相关文章:

ios - 使用 NSProgress 查找下载速度和剩余时间

ios - RootViewController 的 viewDidLoad 中的 UIAlertView 在 iOS 7 中突然不起作用

ios - 在 MMDrawerController 上传递数据

ios - 同步更新 UITableView 的模式?

swift - 静态 TableView 单元格中的 socket

ios - 当用户按下按钮时显示 SplitViewController?

ios - 如何使用导航将字符串从一个 tableViewController 传递到另一个 tableViewController

ios - 导航栏导航项导致推送 View Controller 上按钮的顶部区域不可点击

iphone - activityIndi​​catorView 中的问题显示在 UITableViewController 中?

ios - UISearchBar搜索功能不起作用