我希望设置一个处理我的UIPageViewControllerDataSource的VC,但无论出于何种原因我都会收到此错误。我需要包含其他协议吗?我的代码:
class ViewController: UIViewController, UIPageViewControllerDelegate, UIPageViewControllerDataSource
谢谢!
答案 0 :(得分:1)
为自定义类添加协议定义是不够的。您必须至少提供UIPageViewControllerDataSource
协议所需的两个功能:
func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController?
func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController?
在UIPageViewControllerDataSource Protocol Reference文档中仔细查看您可以在课程中实现的方法。
答案 1 :(得分:0)
您必须实施以下方法:
pageViewController(pageViewController:UIPageViewController,viewControllerAfterViewController viewController:UIViewController) - >的UIViewController?
pageViewController(pageViewController:UIPageViewController,viewControllerBeforeViewController viewController:UIViewController) - >的UIViewController?