1
我已經創建了tableview,並在tableview單元格中給出了另一個子tableview,並且能夠在兩個表視圖中填充數據,但不能給出tableview的自動增量高度,我給出了約束高度也在tableview單元格但它不增加子tableview的高度,當我給主tableview中的子tableview約束高度它給我錯誤所以如何增加子tableview的高度?基於contentSize增加tableview的高度
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == tableview1{
return fees.count
}else{
return descriptionFe.count
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == tableview1{
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! FeesTableViewCell
let getdata = fees[indexPath.row]
cell.billno_txt.text = getdata.Billno
let date = getdata.recivedDate
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
let dateFromString : NSDate = dateFormatter.date(from: date)! as NSDate
dateFormatter.dateFormat = "dd-MM-yyyy"
let datenew = dateFormatter.string(from: dateFromString as Date)
cell.received_date_txt.text = datenew
cell.status_txt.text = getdata.status
cell.total_amount_txt.text = getdata.AmountPaid
let date1 = getdata.recivedDate
let dateFormatter1 = DateFormatter()
dateFormatter1.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
let dateFromString1 : NSDate = dateFormatter1.date(from: date1)! as NSDate
dateFormatter1.dateFormat = "dd-MM-yyyy"
let datenew1 = dateFormatter1.string(from: dateFromString1 as Date)
cell.date_txt.text = datenew1
return cell
}
else{
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! FeesTableViewCell
//
cell.innertableviewheight.constant = tableView.contentSize.height
cell.inner_txt1.text = fees[indexPath.row].Billno
cell.inner_txt2.text = fees[indexPath.row].AmountPaid
return cell
}
}
子的tableview細胞
class FeesTableViewCell: UITableViewCell{
@IBOutlet weak var billno_txt: UILabel!
@IBOutlet weak var date_txt: UILabel!
@IBOutlet weak var total_amount_txt: UILabel!
@IBOutlet weak var status_txt: UILabel!
@IBOutlet weak var received_date_txt: UILabel!
@IBOutlet weak var innertableviewheight: NSLayoutConstraint!
@IBOutlet weak var inner_txt1: UILabel!
@IBOutlet weak var inner_txt2: UILabel!
@IBOutlet weak var inner_tableview: UITableView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override init(style: UITableViewCellStyle, reuseIdentifier: String!) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
innertableviewheight.constant = inner_tableview.contentSize.height
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
// fatalError("init(coder:) has not been implemented")
}
}
我'混淆,我們可以增加主表視圖細胞內子的tableview的高度。我需要一些建議。
如何給數組大小您能不能給這裏的例子 –
更新我的回答如與代碼 –
雅我得到這但是如何在上面的代碼中完成,我很困惑 –