我有一系列VC在pageviewcontroller中包含一个tableview,当它显示第一个视图时,一切都很好并调用了委托。
然而,在滑动视图后,我仍然可以看到VC的背景颜色,调试器显示表被添加到视图中,但是没有内容。这似乎是由于没有调用委托方法引起的,但它与创建工作初始视图的控制器模板相同。可能是什么原因造成的?
页面控制器设置的代码,子视图使用通常的委托方法设置为典型的表视图:
CFont::CreatePointFontIndirect
VDL设置:
extension PollContainerViewController: UIPageViewControllerDataSource {
func viewControllerAtIndex(index: Int) -> PollQuestionAndResultViewController? {
if self.selectedPoll.questions.count == 0 || index >= self.selectedPoll.questions.count {
return nil
}
let PollQuestionResultViewController = PollQuestionAndResultViewController(pollQuestionView: PollQuestionAndResultView(frame: UIScreen.main.bounds), selectedPoll: self.selectedPoll, pageID: self.pageID, pageIndex: index)
return PollQuestionResultViewController
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard var index = (viewController as! PollQuestionAndResultViewController).pageIndex else {return nil}
pageControl.currentPage = index
if (index <= 0) {
return nil
}
index -= 1
return self.viewControllerAtIndex(index: index)
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard var index = (viewController as! PollQuestionAndResultViewController).pageIndex else {return nil}
pageControl.currentPage = index
index += 1
if (index >= self.selectedPoll.questions.count) {
return nil
}
return self.viewControllerAtIndex(index: index)
}
调试器图片: