varun
varun

Reputation: 317

PageViewController not Working

I am integrating PageViewController. I am getting an error.

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

Upvotes: 0

Views: 53

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100503

The problem is in the module if you looked under the class name in identity inspector you will find module is None , focus on class and click enter or check Inherit Module From Target

Upvotes: 2

Related Questions