내부에 UITableView가있는 MainViewController라는 재사용 뷰 컨트롤러가 필요합니다. 내 MainViewController의 많은 서브 클래스가 필요 많은 서브 클래스에서 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
}
은 사용자 정의 그들을 내 요구의 따라 할 수 있습니다. IntroViewController가 그 중 하나입니다. 라인
self.tableView.dataSource = self
에 대한
fatal error: unexpectedly found nil while unwrapping an Optional value
:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "intro" {
let destination = segue.destination as! UINavigationController
let ivc = destination.topViewController as! IntroViewController
}
}
내가이 사고를 가지고 :
class IntroViewController: MainViewController {
}
여기, 내 SEGUE을 IntroViewController를 열려면
콘센트가 올바르게 연결되었는지 확인했습니다. 데이터 소스도 있습니다.
StoryViewController 란 무엇입니까? –
MainViewController, 수정했습니다. – cmii
두 컨트롤러 사이의 탐색 컨트롤러. –