Я установил приблизительную высоту и высоту просмотра таблицы в UIAutomaticDimension, но у меня увеличивается высота надписи.
Я пытался изменить label.preferredMaxLayoutWidth
, но все еще не работал.
Я установил приблизительную высоту и высоту просмотра таблицы в UIAutomaticDimension, но у меня увеличивается высота надписи.
Я пытался изменить label.preferredMaxLayoutWidth
, но все еще не работал.
func numberOfSections (в tableView: UITableView) -> Int {
возврат 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if let buildingArr = buildingViolationArray {
return buildingArr.count
}
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: Language.sharedInstance.isEnglish ? "CELL" : "CELL_AR", for: indexPath) as! BuildingViolationHeaderTableViewCell
if let buildingViolationsDict = buildingViolationArray?[indexPath.row] {
cell.followUpNoLbl.text = buildingViolationsDict["followupNo"] as? String
cell.violationTypeLbl.text = buildingViolationsDict[Language.sharedInstance.isEnglish ? "violationType" : "violationTypeArb"] as? String
cell.bvBtn.addTarget(self, action: #selector(BuildinVioClicked), for: .touchUpInside)
if buildingViolationsDict[kIsSelectedKey] as? Bool == true {
cell.isCellSelected = true
let buildingVioView = getZoneRegView(buildingViolationsDict)
buildingVioView.tag = 1
for removeSubViews in cell.bvStackView.subviews {
removeSubViews.removeFromSuperview()
cell.bvStackView.removeArrangedSubview(removeSubViews)
}
cell.bvStackView.addArrangedSubview(buildingVioView)
cell.expandImage.image = UIImage(named: "minus-256")
} else {
cell.isCellSelected = false
for removeSubViews in cell.bvStackView.subviews {
removeSubViews.removeFromSuperview()
cell.bvStackView.removeArrangedSubview(removeSubViews)
}
cell.expandImage.image = UIImage(named: "plus-256")
}
cell.violationTypeLbl.preferredMaxLayoutWidth = cell.violationTypeLbl.frame.size.width
}
cell.selectionStyle = .none
return cell
}
func BuildinVioClicked(sender: UIButton){
let location = sender.convert(CGPoint.zero, to: bvTableView)
let indexPath = bvTableView.indexPathForRow(at: location)!
if var buildingViolationsDict = buildingViolationArray?[indexPath.row] {
if let isSelect = buildingViolationsDict[kIsSelectedKey] as? Bool, isSelect {
(buildingViolationArray[indexPath.row])[kIsSelectedKey] = false
} else {
(buildingViolationArray[indexPath.row])[kIsSelectedKey] = true
}
bvTableView.reloadData()
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}