PageViewController不起作用

时间:2018-07-21 11:55:33

标签: ios swift uipageviewcontroller

我正在集成PageViewController。我遇到了错误。

  

无法将类型'UIViewController'(0x105390ca8)的值强制转换为'VeggieIndia.PageContentViewController'(0x10273bc98)。

override func viewDidLoad() {
    super.viewDidLoad()

    arrPagePhoto = ["background", "background", "3.jpg"];

    self.setViewControllers([getViewControllerAtIndex(index: 0)], direction: .forward, animated: true) { (true) in

    }

    self.dataSource = self

    //  self.setViewControllers([getViewControllerAtIndex[0]] as [UIViewController], direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)

    // Do any additional setup after loading the view, typically from a nib.
}

func getViewControllerAtIndex(index: NSInteger) -> PageContentViewController {
    // Create a new view controller and pass suitable data.
    let pageContentViewController = self.storyboard?.instantiateViewController(withIdentifier: "PageContentViewController") as! PageContentViewController
    pageContentViewController.strPhotoName = "\(arrPagePhoto[index])"

    pageContentViewController.pageIndex = index
    return pageContentViewController
}

enter image description here

1 个答案:

答案 0 :(得分:2)

问题出在模块中,如果您在身份检查器中的类名称下查看,您会发现模块为None,将其放在类上,然后单击Enter或选中Inherit Module From Target