开发者社区> 问答> 正文

检查是否在UITableView的区段中选择了单元格

我想要创建一个简单的func,它将验证我的部分,并查看在我的部分中是否至少有一个单元格被选中,以便它返回我的信息。

就像这样:

func checkSections () ->Bool {

    let array : [IndexPath] = self.selectedIndexPaths.copy() as! [IndexPath];
    for indexPath: IndexPath in array {
        let SectionString : String? = self.sectionHeaderTitleArray[indexPath.section] // this will return the names of the selected sections but no way to use that

        // check all the sections and see if they contain a selected cell
    }



}

我知道这是不完整的,但我不知道如何开始创建它,我希望至少能找到一些帮助来启动这个功能。请理解,我已经5年多没有接触过任何与编程相关的东西了,而且我从来就不是一个专业人士。

展开
收起
游客5akardh5cojhg 2019-12-05 16:26:16 448 0
1 条回答
写回答
取消 提交回答
  • 试试这个:

    class CheckableTableView: UITableView {
    
        func checkSections() -> Bool {
            return indexPathsForSelectedRows != nil
        }
    
    }
    
    2019-12-05 16:26:45
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载