My objective is make a screen like this:
This is the screen that I've implemented with StackView and Labels. But now, I want to do this with a UITableView. My problem is that Cells needs to be dynamic. Because a text can be different from the others. So I've started creating a UITableViewCell with your xib file (the backgroud grey is to design)
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 with 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
}
}