reloadData Handler cellForRowAt debug
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
window = UIWindow(frame: UIScreen.main.bounds) | |
let aVC = AViewController() | |
let nav = UINavigationController(rootViewController: aVC) | |
window!.rootViewController = nav | |
window!.makeKeyAndVisible() | |
return true | |
} |
import UIKit | |
class BViewController: UIViewController { | |
@IBOutlet var handlerButton: UIButton! { | |
didSet { | |
handlerButton.addTarget(self, action: #selector(doHandler), for: .touchUpInside) | |
} | |
} | |
var handler: (() -> Void) = {} | |
override func viewWillDisappear(_ animated: Bool) { | |
super.viewWillDisappear(animated) | |
print("Disappearing") | |
} | |
@objc private func doHandler() { | |
handler() | |
} | |
} |
import UIKit | |
class AViewController: UIViewController { | |
@IBOutlet var pushButton: UIButton! { | |
didSet { | |
pushButton.addTarget(self, action: #selector(pushBVC), for: .touchUpInside) | |
} | |
} | |
@IBOutlet var tableView: UITableView! { | |
didSet { | |
tableView.dataSource = self | |
} | |
} | |
@objc private func pushBVC() { | |
let bVC = BViewController() | |
bVC.handler = { | |
print("handling") | |
self.tableView.reloadData() | |
} | |
navigationController?.pushViewController(bVC, animated: true) | |
} | |
} | |
extension AViewController: UITableViewDataSource { | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return 20 | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
print("CellForROwAt") | |
return UITableViewCell() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment