Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift如何从按钮将我的Tableview单元格accessoryType重置为.None_Ios_Swift_Uitableview_Accessorytype - Fatal编程技术网

Ios Swift如何从按钮将我的Tableview单元格accessoryType重置为.None

Ios Swift如何从按钮将我的Tableview单元格accessoryType重置为.None,ios,swift,uitableview,accessorytype,Ios,Swift,Uitableview,Accessorytype,我是iOS开发的初学者,正在使用swift 我正在尝试编写一个简单的待办事项列表应用程序。在这里,您可以在完成后选中项目,并单击“完成”按钮一次性将其全部删除 将所选项目存储在阵列中,然后从主阵列中删除后,该按钮已成功删除这些项目 “完成”按钮代码如下所示 @IBAction func btnDone(sender: AnyObject) { for i in selectedItems { items.removeAtIndex(i) } tab

我是iOS开发的初学者,正在使用swift

我正在尝试编写一个简单的待办事项列表应用程序。在这里,您可以在完成后选中项目,并单击“完成”按钮一次性将其全部删除

将所选项目存储在阵列中,然后从主阵列中删除后,该按钮已成功删除这些项目

“完成”按钮代码如下所示

    @IBAction func btnDone(sender: AnyObject) {
    for i in selectedItems {
        items.removeAtIndex(i)
    }
    tableview.reloadData()
}
但问题是,标记的复选框没有进入(或重置为.None)

我在以下链接上找到了一个易于实施的解决方案:

但不幸的是,在Objective-C中,是否有人能翻译成Swift或提供类似的解决方案请尝试一下

        @IBAction func btnDone(sender: AnyObject) {
            for (var section = 0, sectionCount = tableView.numberOfSections; section < sectionCount; ++section) {
                for (var row = 0, rowCount = tableView.numberOfRowsInSection(section); row < rowCount; ++row) {
                    var cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: row, inSection: section))
                    cell!.accessoryType = UITableViewCellAccessoryType.None
                    cell!.selectionStyle = UITableViewCellSelectionStyle.None
                }
            }
        }
@IBAction func btnDone(发送方:AnyObject){
对于(var section=0,sectionCount=tableView.numberOfSections;section
谢谢,swift 2只做了一个小改动,从“var单元”改为“let单元”,效果很好。与objective-C解决方案相比,它看起来有多相似,这让我感到很沮丧。@Hussainscheer,今年,它应该是Swift 2的“let cell”!