[英]UITableView with custom cells not entering editing mode
I have a UITableView with custom UITableViewCells. 我有一个UITableView与自定义UITableViewCells。
The table has two sections, the first section has a single row with a UITextField and can only be edited in terms of the text. 该表有两个部分,第一部分有一行带有UITextField,只能根据文本进行编辑。 This section & row cannot be edited from a UITableView perspective
无法从UITableView透视图编辑此部分和行
The second section is a list of cells that are generated from an NSArray. 第二部分是从NSArray生成的单元格列表。 These cells are once again custom UITableViewCells comprising of two UITextFields.
这些单元格再次是由两个UITextField组成的自定义UITableViewCells。 These cells can be edited from a UITableView perspective, in the sense that the user can delete and insert rows.
从用户可以删除和插入行的意义上来说,可以从UITableView透视图编辑这些单元格。
In my designated initializer I have specified self.tableView.editing = YES
, also I have implemented the method canEditRowAtIndexPath
to return YES. 在我指定的初始化程序中,我指定了
self.tableView.editing = YES
,我也实现了方法canEditRowAtIndexPath
以返回YES。
Problem Statement 问题陈述
The table view does not enter editing mode. 表格视图不会进入编辑模式。 I do not see the delete buttons or insert buttons against the rows of section 2. What am I missing?
我没有看到删除按钮或插入第2节行的按钮。我缺少什么?
just a suggestion, check whether your controller fit to these requirements : 只是一个建议,检查您的控制器是否符合这些要求:
i use usual UIViewController and it works fine - you need to : 我使用通常的UIViewController,它工作正常 - 你需要:
Piece of code :) 一段代码:)
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
[self.tableView setEditing:editing animated:YES];
}
- (void)tableView
:(UITableView *)tableView didSelectRowAtIndexPath
:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
[self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
// do not forget interface in header file
@interface ContactsController : ViewController<
UITableViewDelegate,
UITableViewDataSource>
Profit! 利润!
What if you do [self tableView setEditing:YES animated:YES];
如果你这样做
[self tableView setEditing:YES animated:YES];
instead of self.tableView.editing = YES;
而不是
self.tableView.editing = YES;
? ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.