Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.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 在TableView中展开并可滑动单元格_Ios_Swift_Uitableview - Fatal编程技术网

Ios 在TableView中展开并可滑动单元格

Ios 在TableView中展开并可滑动单元格,ios,swift,uitableview,Ios,Swift,Uitableview,我有TableView,用户可以在其中单击并展开每个单元格(UI:)。这是它的代码(我还创建了.xib文件来布局此单元格): 此外,所有单元格都可以刷卡。代码如下: func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? { let edit = UITableViewRowAction(style: .normal, title:

我有
TableView
,用户可以在其中单击并展开每个单元格(UI:)。这是它的代码(我还创建了
.xib
文件来布局此单元格):

此外,所有单元格都可以刷卡。代码如下:

func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
        let edit = UITableViewRowAction(style: .normal, title: "Edit") { action, index in
            print("Edit")
        }
        edit.backgroundColor = .blue

        let delete = UITableViewRowAction(style: .normal, title: "Delete") { action, index in
            print("Delete")
        }
        delete.backgroundColor = .red

        return [delete, edit]
    }

    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        return true
    }
问题:


当我刷手机的时候,它总是在一个半小时内用完,这是我刷手机后的界面:。如果我滑动单元格,是否可以不展开它们?

对不起,问题是我没有为单元格的展开版本设置约束。这就是为什么标签会随着滑动菜单移动。现在它起作用了。
谢谢你的回复

对不起,问题是我没有为单元格的扩展版本设置约束。这就是为什么标签会随着滑动菜单移动。现在它起作用了。
谢谢你的回复

你能在didSelectRowAt方法中放置一个调试点,然后在滑动时查看,这个方法被调用了吗?你的扩展函数func didExpandCell()不是不正确吗?比方说,若我点击Cell1,IsExpend=true,它就会打开Cell。再次,如果我点击Cell2,它将设置isExpended=false,而不是扩展Cell2。不,它没有在swipeHm上调用,看起来你是对的,以前没有提到过。顺便说一句,我该如何改进它?您能在heightForRowAt方法中设置一个调试点,并检查在您刷卡时它是否被调用吗?我做了一个虚拟项目,它不会引起问题。你能在didSelectRowAt方法中放置一个调试点,然后在滑动时查看,这个方法被调用了吗?你的扩展函数func didExpandCell()不是不正确吗?比方说,若我点击Cell1,IsExpend=true,它就会打开Cell。再次,如果我点击Cell2,它将设置isExpended=false,而不是扩展Cell2。不,它没有在swipeHm上调用,看起来你是对的,以前没有提到过。顺便说一句,我该如何改进它?您能在heightForRowAt方法中设置一个调试点,并检查在您刷卡时它是否被调用吗?我做了一个虚拟项目,它不会引起问题
func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
        let edit = UITableViewRowAction(style: .normal, title: "Edit") { action, index in
            print("Edit")
        }
        edit.backgroundColor = .blue

        let delete = UITableViewRowAction(style: .normal, title: "Delete") { action, index in
            print("Delete")
        }
        delete.backgroundColor = .red

        return [delete, edit]
    }

    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        return true
    }