在tableFooterView中的自定义单元格上设置editingStyle [英] Setting editingStyle on custom cell in tableFooterView
问题描述
以下代码(位于我的-viewWillAppear
中)成功地将一个单元实现为tableFooterView:
The following code (located in my -viewWillAppear
) successfully implements a cell as a tableFooterView:
CGRect cellRect = [self.tableView rectForRowAtIndexPath:0];
UITableViewCell *footerCell = [[UITableViewCell alloc] initWithFrame:cellRect];
//footerCell.editingStyle = UITableViewCellEditingStyleInsert;
footerCell.textLabel.text = @"Add New Class";
self.tableView.tableFooterView = footerCell;
但是,注释掉的行返回此错误:无法设置对象-只读属性或未找到setter
However, the line that is commented out returns this error: object cannot be set - either readonly property or no setter found
如何设置要插入的此单元格的editingStyle?
How can I set the editingStyle of this cell to insert?
推荐答案
通常,UITableViewCell
实例仅用于UITableView
行,而不能用于页脚本身.但是,由于它是UIView
的子类,所以我想它会起作用.
Normally UITableViewCell
instances are meant to only go into UITableView
"rows" and not into the footer itself. However since it is subclass of UIView
I guess it will work.
您遇到的问题是它是一个只读属性.您尝试设置的信息通常由UITableView
通过委托发现.因此,您正在尝试将方钉插入圆孔中.
The issue you are having is that it is a readonly property. The information you are trying to set is normally discovered by the UITableView
through delegates. Therefore you are trying to put a square peg into a round hole.
我会创建一个自定义的UIView
放在页脚中,而不是尝试在其中放置UITableViewCell
.
I would create a custom UIView
to put into your footer instead of trying to put a UITableViewCell
in there.
这篇关于在tableFooterView中的自定义单元格上设置editingStyle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!