即使在实现委托方法后也没有显示页面控件
Posted
技术标签:
【中文标题】即使在实现委托方法后也没有显示页面控件【英文标题】:no page control displayed even after implementing delegate methods 【发布时间】:2017-02-13 04:59:57 【问题描述】:添加委托和数据源后,页面视图控制器不显示。如何实现pageViewController数据源和委托
import UIKit
数据源
class PageViewController: UIPageViewController ,UIPageViewControllerDataSource,UIPageViewControllerDelegate
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController?
let vc = storyboard?.instantiateViewController(withIdentifier: "vc") as! ViewController
return vc
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController?
let vc = storyboard?.instantiateViewController(withIdentifier: "vc") as! ViewController
return vc
func presentationCount(for pageViewController: UIPageViewController) -> Int
return 3
override func index(ofAccessibilityElement element: Any) -> Int
return 0
在 ViewDidLoad 中设置委托和数据源
override func viewDidLoad()
super.viewDidLoad()
dataSource=self
delegate = self
let vc = storyboard?.instantiateViewController(withIdentifier: "vc") as! ViewController
self.setViewControllers([vc], direction: .forward, animated: true, completion: nil)
override func didReceiveMemoryWarning()
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
【问题讨论】:
【参考方案1】:替换
override func index(ofAccessibilityElement element: Any) -> Int
return 0
与
func presentationIndex(for pageViewController: UIPageViewController) -> Int
return 0
完成了工作。
我调用了错误的方法
【讨论】:
以上是关于即使在实现委托方法后也没有显示页面控件的主要内容,如果未能解决你的问题,请参考以下文章