ios - PageViewController 不工作

标签 ios swift uipageviewcontroller

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

Could not cast value of type 'UIViewController' (0x105390ca8) to '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

最佳答案

问题出在模块中,如果您在身份检查器中查看类名,您会发现模块是 None ,关注类并单击 enter 或选中 Inherit Module From Target

关于ios - PageViewController 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51455807/

相关文章:

javascript - 为什么当我点击它时我的子菜单不显示

ios - CocoaPods 未正确安装

swift - 在 Swift (5) 中,如何将 "Any..."参数传递给 print() 语句而不将其打印为数组?

ios - 如何在 iOS 中自动滚动页面 View Controller ?

ios - UIPageViewController 断言失败

ios - Facebook LoginManager 回调/PrepareforSegue Swift

ios - 从图像文件创建 CIImage 模式

ios - 具有 Web + iOS 应用程序身份验证的 Rails Azure Active Directory SSO

ios - 如何让 UIImageView 的边缘捕捉到屏幕( super View )的边缘?

ios - 如何使我的页面 View Controller 不至于无穷无尽?