停止 table 生成已删除的单元格
Stop table from generating cell that has already been deleted
这是我用来在我的 RSS 提要中生成常规 table 单元格的代码 reader:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// Function adds the title to each cell
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
let item = feedItems[indexPath.row] as MWFeedItem
cell.textLabel?.text = item.title
return cell
}
我想在上面的函数中添加一个 if 语句,这将在提要已被用户删除的情况下停止函数生成 table 单元格。我知道如何检查它是否已被删除(if 后括号内的内容),但不知道我将在实际 if 语句中放入的内容。
if(/*table cell has been deleted*/)
{
/*code that stops this feed from being regenerated*/
}
执行此操作的方法是从 feedItems
中实际删除或删除项目,然后使用 tableView.reloadData()
重新加载 tableView
。然后这将提供正确数量的元素给 tableView
只绘制 feedItems
.
中包含的所有元素
希望对您有所帮助。
这是我用来在我的 RSS 提要中生成常规 table 单元格的代码 reader:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// Function adds the title to each cell
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
let item = feedItems[indexPath.row] as MWFeedItem
cell.textLabel?.text = item.title
return cell
}
我想在上面的函数中添加一个 if 语句,这将在提要已被用户删除的情况下停止函数生成 table 单元格。我知道如何检查它是否已被删除(if 后括号内的内容),但不知道我将在实际 if 语句中放入的内容。
if(/*table cell has been deleted*/)
{
/*code that stops this feed from being regenerated*/
}
执行此操作的方法是从 feedItems
中实际删除或删除项目,然后使用 tableView.reloadData()
重新加载 tableView
。然后这将提供正确数量的元素给 tableView
只绘制 feedItems
.
希望对您有所帮助。