[ad_1]
I’ve an issue so i’ve tableVC (and cells)in programmatically.
class InitialTableVC: UITableViewController {
static var shared = InitialTableVC()
var bookList = [BooksModel]()
override func viewDidLoad() {
tremendous.viewDidLoad()
tableView.register(Cell.self, forCellReuseIdentifier: "CellIdentity")
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, goal: self, motion: #selector(addSomeBook))
self.navigationItem.rightBarButtonItem?.tintColor = UIColor.blue
}
//this how i attempt to change viewController
@objc func addSomeBook() {
let vc = BookVC()
self.navigationController?.pushViewController(vc, animated: true)
self.navigationController?.modalPresentationStyle = .overCurrentContext
}
// MARK: - Desk view knowledge supply
override func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
// #warning Incomplete implementation, return the variety of rows
return bookList.rely
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CellIdentity", for: indexPath) as! Cell
let currentBook = bookList[indexPath.row]
cell.bookLabel.textual content = currentBook.e-book
cell.authorLabel.textual content = currentBook.creator
cell.imageBook.picture = UIImage(named: currentBook.bm) ?? #imageLiteral(resourceName: "liter")
return cell
}
}
and This my SecondVC and on this VC i am attempting to ship information from UITextFields to Labels in first VC however when i transfer to firstVC my labels dont have information
class BookVC: UIViewController {
non-public lazy var customView = BookView()
override func loadView() {
view = customView
}
override func viewDidLoad() {
tremendous.viewDidLoad()
customView.button.addTarget(self, motion: #selector(newBookLabel), for: .touchUpInside)
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, goal: self, motion: #selector(again))
}
@objc func newBookLabel() {
let mod = BooksModel()
mod.e-book = customView.tf.textual content ?? "error"
mod.creator = customView.secondTf.textual content ?? "d"
InitialTableVC.shared.bookList.append(mod)
navigationController?.popViewController(animated: true)
}
@objc func again() {
navigationController?.popViewController(animated: true)
}
}
[ad_2]
