【问题标题】:SWIFT : expand / collapse custom cell from UIswitch in the custom cellSWIFT:从自定义单元格中的 UIswitch 展开/折叠自定义单元格
【发布时间】:2017-08-22 22:14:31
【问题描述】:

在我的viewcontroller, 我添加了我的表格视图 (@IBOutlet weak var MyTableView: UITableView!),其中我添加了几个具有特定大小的自定义单元格,具体大小取决于内部所需的元素。 我用identifier 调用每个单元格:

func tableView(_ MyTableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    if indexPath.row == 0 {
        let cell = MyTableView.dequeueReusableCell(withIdentifier: "FirstCell") as! FirstCell
        self.SettingsTableView.rowHeight = 220
        return cell
    } else if indexPath.row == 1 { etc etc...

在特定行,我直接在单元格中添加了一个 UIswitch,它应该根据它是打开还是关闭来展开/折叠此单元格。 我想让它工作起来有点像SelectRowAtIndexPath 方法并对其进行动画处理以使其出现在下面的 3 个文本字段......

我正在寻找几个小时的解决方案,如果您有任何想法...欢迎任何建议!

【问题讨论】:

    标签: ios swift uitableview uiswitch custom-cell


    【解决方案1】:

    如果您的开关正确连接到单元格,问题可能是您没有刷新 UITableView,因此它没有展开。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多