ios - 同时使用 TableFooterView 和行操作时 TableView 分隔符的奇怪行为

标签 ios objective-c uitableview

这是我使用 tableviewcontroller 设置的基本 tableview。重用标识符只是得到一个浅绿色的原型(prototype)单元格。

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 25)];
    [self.tableView.tableFooterView setBackgroundColor:[UIColor colorWithRed:215/255 green:1 blue:1 alpha:1]];
}

- (BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewRowAction *removeFolderRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
                                                                                 title:@"hi"
                                                                               handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
                                               {
                                                   return;
                                               }];

    return @[removeFolderRowAction];
}

- (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    return;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [self.tableView dequeueReusableCellWithIdentifier:@"cell"];
}

@end

这会产生这个流程:

enter image description here enter image description here enter image description here enter image description here

它从没有底部分隔符开始,然后如果您在最后一个单元格上进入编辑模式,仍然没有底部分隔符,但是当完成编辑时,会出现一个全角分隔符,如果您再次进入编辑模式,它就会离开。如果我要让我的 tableFooterView 成为带有框架 CGRectZero 的 View ,它将以预期的方式运行(有一个分隔符,与所有其他分隔符一样,在进入编辑模式时不会移动),但是一旦tableFooterView 有一些高度,它回到像上面的图片一样。

最佳答案

所以我深入研究了一下,iOS 11 为我解决了这个问题。似乎是以前版本的错误。 对我来说,分隔符会显示在触及页眉或页脚的最后一行

关于ios - 同时使用 TableFooterView 和行操作时 TableView 分隔符的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31328463/

相关文章:

ios - 无法在所有设备上获取推送通知

ios - 大于 Unsigned Long Long

ios - 移除 KVO 观察器时 APP 崩溃

ios - 当不存在单元格时,如何向 UITableViewController 添加不同的默认背景?

ios - Swift:string.characters.count 为阿拉伯字符串返回错误的数字

ios - 禁用 UIKeyboard 中的 "GO"按钮,直到满足特定条件

javascript - Fabric js 自定义旋转图标仅在 iphone 的 google chrome 浏览器中不可见

objective-c - 有没有办法限制 UIDocumentInteractionController 中显示的应用程序?

在 UIScrollView 中具有完整高度的 iOS UITableView

ios - 如何使用按钮操作(带参数)从自定义 UITableViewCell 推送 View