这是我使用 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
这会产生这个流程:
它从没有底部分隔符开始,然后如果您在最后一个单元格上进入编辑模式,仍然没有底部分隔符,但是当完成编辑时,会出现一个全角分隔符,如果您再次进入编辑模式,它就会离开。如果我要让我的 tableFooterView 成为带有框架 CGRectZero 的 View ,它将以预期的方式运行(有一个分隔符,与所有其他分隔符一样,在进入编辑模式时不会移动),但是一旦tableFooterView 有一些高度,它回到像上面的图片一样。
最佳答案
所以我深入研究了一下,iOS 11 为我解决了这个问题。似乎是以前版本的错误。 对我来说,分隔符会显示在触及页眉或页脚的最后一行
关于ios - 同时使用 TableFooterView 和行操作时 TableView 分隔符的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31328463/