1
我想有一個可重用的視圖控制器調用MainViewController與UITableView裏面。如何在UITableViewDelegate的子類UIViewController在很多子類
class MainViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tableView : UITableView!
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.dataSource = self
self.tableView.delegate = self
self.tableView.scrollsToTop = true
self.tableView.estimatedRowHeight = 124.0
self.tableView.rowHeight = UITableViewAutomaticDimension
}
我需要我的MainViewController的很多子類,以定製可以根據他們的我的需要。 IntroViewController就是其中之一。
class IntroViewController: MainViewController {
}
要打開IntroViewController,在這裏我賽格瑞:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "intro" {
let destination = segue.destination as! UINavigationController
let ivc = destination.topViewController as! IntroViewController
}
}
我得到這個崩潰:
fatal error: unexpectedly found nil while unwrapping an Optional value
爲線
self.tableView.dataSource = self
我查過了,我的店鋪連接正確。數據源也是。
什麼是StoryViewController? –
MainViewController,我改正了。 – cmii
爲什麼導航控制器之間的2個控制器。? –