简体   繁体   English

快速将表格视图添加到表格视图单元格

[英]add a table view to a table view cell in swift

I want to implement this type of screen.我想实现这种类型的屏幕。 There are two table view one is in right side another one is in left side.有两个表视图,一个在右侧,另一个在左侧。 In left side table (chatOne) view I want to add a table view in its first section (that is chatOneCell).在左侧表 (chatOne) 视图中,我想在其第一部分(即 chatOneCell)中添加一个表视图。 屏幕

How to add a table view to a table view cell in swift?如何快速将表格视图添加到表格视图单元格?

I am trying to add a table view to a table view cell.我正在尝试将表格视图添加到表格视图单元格中。 The outer table is shown successfully .But the inner table is not loading.外表显示成功。但内表未加载。 if i am adding view, Button labels etc. It is showing in the cell but not the table view.如果我要添加视图、按钮标签等。它显示在单元格中,而不是表格视图中。 Please see my code and help me to rectify my problem请查看我的代码并帮助我纠正我的问题

ChatOne is the cell of outer table view ChatOne 是外表视图的单元格

InerTable is the table which i am trying to place in chatOne Cell InerTable 是我想放在 chatOne Cell 中的表格

insideCell is the cell of inerTable insideCell 是 inerTable 的单元格

iner table has tag 45 and ouer has tag 25 iner 表有标签 45,ouer 有标签 25

        class ChatOne: UITableViewCell{

            @IBOutlet weak var inerTable: UITableView!


            override func awakeFromNib() {
                super.awakeFromNib()


                inerTable.dataSource = self as? UITableViewDataSource
                inerTable.delegate = self as? UITableViewDelegate
               inerTable.reloadData()

            }

           }

        class insideCell: UITableViewCell {
            @IBOutlet weak var myLabel: UILabel!
            override func awakeFromNib() {
                super.awakeFromNib()

            }
        }



        public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                if tableView.tag == 45{
                    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! insideCell
                    cell.myLabel.text = "Tapan"
                    return cell
                }
                if tableView.tag == 25{

                    let rowIdentifier = tableOneIdentifire[indexPath.section]
                    let cell = tableView.dequeueReusableCell(withIdentifier: rowIdentifier)
                    return cell!
                }


                return UITableViewCell()

            }

I also have this kind of problems in adding table views in swift .我在 swift 添加表视图时也遇到了这种问题。 so I follow this link and there are all the details clearly .所以我点击了这个链接,所有的细节都很清楚。 so follow this shorturl.at/yKSYZ所以按照这个shorturl.at/yKSYZ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM