Моя цель - создать такой экран:
![enter image description here](https://i.stack.imgur.com/eATIN.png)
Это экран, который я реализовал с помощью StackView и Labels.Но теперь я хочу сделать это с помощью UITableView.Моя проблема в том, что клетки должны быть динамическими.Потому что текст может отличаться от других.Итак, я начал создавать UITableViewCell с вашим xib-файлом (задний серый для дизайна)
![enter image description here](https://i.stack.imgur.com/tup0b.png)
Swift file
class CellCreateSaleVC: UITableViewCell {
@IBOutlet weak var lblInfo: UILabel!
@IBOutlet weak var imgClipboard: UIImageView!
@IBOutlet weak var lblNomeCampo: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
ViewController с UITableView
class CreateSaleViewController : UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableViewMenu: UITableView!
let options : Int = 12
override func viewDidLoad() {
tableViewMenu.dataSource = self
tableViewMenu.delegate = self
tableViewMenu.register(UINib(nibName: "CellCreateSaleVC", bundle: nil), forCellReuseIdentifier: "CellCreateSale")
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return options
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CellCreateSale") as! CellCreateSaleVC
return cell
}
}
Но мой результат таков: ![enter image description here](https://i.stack.imgur.com/QiCre.png)