-1
頁面視圖控制器在添加委託和數據源後不顯示。如何實現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.
}
}
我仍然無法看到頁面控制 – CazzyTheCoder
你不能看到什麼?頁面控制器/ pageViewController –
頁面控制器 – CazzyTheCoder