gpt4 book ai didi

iphone - Swift - TableView 如何创建可扩展部分

转载 作者:行者123 更新时间:2023-11-30 12:49:12 26 4
gpt4 key购买 nike

我想用 swift 创建一个可扩展的部分。例如,在下图中,Microsoft Outlook IOS 应用程序有一个可扩展部分。

enter image description here

当您单击该部分时,如下所示。

enter image description here

此部分是否需要额外的代码或 xcode 已经具有此功能?提前致谢。

最佳答案

您需要为您创建的自定义部分创建一个委托(delegate),将其分配给 ViewController 并在委托(delegate)方法中当用户点击它时调用它。

insertRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation)

当用户再次点击该部分时,检查该部分是否打开,如果是,则调用此方法。

deleteRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation)

并且不要忘记在这些方法之后调用 tableView.reloadData()

关于iphone - Swift - TableView 如何创建可扩展部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41221058/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com