Please really I need help on this issue it has taken 6 days from me, and I can not find a solution.
I want to make simple table view but its cells always have static height not changed upon items inside it
The result always like this image from emulator.
I want to show this in every cell as example:
1 1 11 1 1111 1 1 11 11 11 1 1 1 11 1 1 11 11 1 11 1 11 11 11
22 22 2 2 2 2 2 2 2 2 2 2 2 22 22 22 22 2 2 22 2 2 2 2 22 2 2 22
33 33 3 3 3 3 3 3 3 3 3 3 3 3 3 3 33 3 3 3 33 33 3 3 3 3 3 333 3 3 3 3
444 44 4 44 444 4 4 4 4 4 4 4 4 4 4 44 4 4 44 4 4 4 4 4 4 4 44 44 4
it must be shown in 4 labels in vertical-align but result as you see before
I tried all ways like making view using storyboard or from code but finally, I used library called Stevia but still same result
This is view controller
class AttendanceControlPage:UIViewController,UITableViewDataSource,UITableViewDelegate {
@IBOutlet weak var dataTableView: UITableView!
@IBOutlet weak var navLeftButton: UIBarButtonItem!
//============================ Base Functions =================//
override func viewDidLoad() {
super.viewDidLoad()
// Some tutorials said to put this two lines but not changes
dataTableView.estimatedRowHeight = 44
dataTableView.rowHeight = UITableViewAutomaticDimension
initPage()
dataTableView.register(AttendanceControlCell.self, forCellReuseIdentifier: "cellCon")
}
//============================ Init Functions =================//
func initPage() {
startLoading()
self.navLeftButton.image = UIImage(named: "icn_drawer")
}
//==================== Nav Bar Buttons Actions ===================================//
@IBAction func reloadPage(_ sender: Any) {
self.dataArray.removeAll()
loadData();
}
@IBAction func navLeftButtonAction(_ sender: Any) {
showMenu()
}
//==================== Table view options ===================================//
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 6
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = dataTableView.dequeueReusableCell(withIdentifier: "cellCon", for: indexPath) as! AttendanceControlCell
return cell
}
}
This is Cell file :
class AttendanceControlCell: UITableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
initFunc(cell : self)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
func initFunc(cell : UITableViewCell) {
let name1 = UILabel()
name1.numberOfLines = 0
name1.text = "1 1 11 1 1111 1 1 11 11 11 1 1 1 11 1 1 11 11 1 11 1 11 11 11 "
let name2 = UILabel()
name2.numberOfLines = 0
name2.text = "22 22 2 2 2 2 2 2 2 2 2 2 2 22 22 22 22 2 2 22 2 2 2 2 22 2 2 22 "
let name3 = UILabel()
name3.numberOfLines = 0
name3.text = "33 33 3 3 3 3 3 3 3 3 3 3 3 3 3 3 33 3 3 3 33 33 3 3 3 3 3 333 3 3 3 3 "
let name4 = UILabel()
name4.numberOfLines = 0
name4.text = "444 44 4 44 444 4 4 4 4 4 4 4 4 4 4 44 4 4 44 4 4 4 4 4 4 4 44 44 4 "
cell.contentView.sv(
name1,
name2,
name3,
name4
)
layout(
20,
|name1|,
20,
|name2|,
20,
|name3|,
20,
|name4|
)
}
override func awakeFromNib() {
super.awakeFromNib()
}
}
And this is my storyboard: contain only tableview with cell inisde it only
Please really i need help