可展开的UITableview内部tableview高度不增加

时间:2018-03-09 07:28:42

标签: ios swift uitableview expandable-table

您好我正在尝试实施Expandable UITableview扩展单元格并且内部有tableview

当我从外部表视图重新加载默认的内部tableview时,在设置内容后,只有部分内部tableview可见,我尝试对行的高度进行硬编码但不能正常工作

请咨询

func reloadexpandtableview (tablearray: AnyObject, indexpath : IndexPath , controller : UIViewController,tag: Int)  {
    if tag == 1 {

        self.additivesArray = tablearray as! List<Items>
        self.isAdditives = true
       // here height constraint constant works.. but the height is same even after loading the cells with data..
        self.tablview_height.constant = CGFloat(additivesArray.count * 44);
        self.indexpath = indexpath;
        self.tableview.reloadData()
    }
}
// MARK: - tableview delegates
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{            
     return self.additivesArray.count
}


func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    var cell : UITableViewCell!
    cell = UITableViewCell(style: UITableViewCellStyle.subtitle, reuseIdentifier: "cell")
    cell.selectionStyle = .none;
    let additives = self.additivesArray[indexPath.row]
    cell.textLabel?.numberOfLines = 0
    cell.textLabel?.lineBreakMode = .byWordWrapping
    cell.textLabel?.text = additives.desc
    cell.detailTextLabel?.text = additives.ingredient

    return cell;
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

In the image "other" cell has 3 inner cells but only first half of the first cell is visible

in the image "other" cell has 3 inner cells but only first half of the first cell is visible

0 个答案:

没有答案