从堆栈弹出后,UITableViewCellSeperator的问题再次出现

编程入门 行业动态 更新时间:2024-10-10 05:25:02
本文介绍了从堆栈弹出后,UITableViewCellSeperator的问题再次出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have an application with dynamic data loaded into a tableview. When there is only one item (thus only one cell). To make sure that the UITableViewCellSeperator is not showing up for this one item I am using this code:

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { // This will create a "invisible" footer return 0.01f; }

这是按预期工作的,这是我的单元格看起来像:

This works as expected and here is what my cell looks like:

正如您所见,这可以按预期工作,并且没有单元格分隔符。

As you can see this works as expected and there is no cell separator.

当我选择单元格并显示我的详细信息视图然后点击后退按钮时,单元格会因某种原因添加分隔符。一旦我在堆栈中导航,这就是单元格的样子:

When I select the cell and display my detail view and then hit the back button, the cell adds a separator for some reason. Here is what the cell looks like once I navigate back in the stack:

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

You will notice that the separator is now wider than the standard separator. If my tableview has more than one cell in it, the last cell in the tableview will behave this same way.

当我删除上述方法时,问题已修复,但现在我的tableview有一个额外的空单元分隔符TON。有更好的解决方案吗?

When I remove the above method, the issue is fixed, but now my tableview has a TON of extra separators for empty cells. Is there a better solution?

这是我的cellForRowAtIndexPath方法:

Here is my cellForRowAtIndexPath method:

- (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; }

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

Any idea what is causing the issue? Or am I doing something wrong? Thanks!

推荐答案

你可以通过以下两种方式做到这一点

you can do this by following two way

首先是

[self.tbl setSeparatorStyle:UITableViewCellSeparatorStyleNone];

其次是

将您的tableview属性从默认更改 到无

change your tableview property from "default" to "none"

更多推荐

从堆栈弹出后,UITableViewCellSeperator的问题再次出现

本文发布于:2023-10-27 23:51:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534891.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:堆栈   弹出   UITableViewCellSeperator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!