PageViewController 不工作
PageViewController not Working
我正在整合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
}
问题出在模块中,如果您在身份检查器中查看 class 名称,您会发现模块是 None ,关注 class 并单击回车或检查 Inherit Module From Target
我正在整合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
}
问题出在模块中,如果您在身份检查器中查看 class 名称,您会发现模块是 None ,关注 class 并单击回车或检查 Inherit Module From Target