Swift pagecontroller故事板UI对象与UIPageviewController连接

时间:2018-09-06 09:39:39

标签: ios swift uipageviewcontroller uipagecontrol

我已经在容器视图中完成了pageviewcontroller,我可以使用程序化显示页面控制,但是我通过使用Storyboard实现了容器视图,所以我不知道如何在容器中心显示页面控制器。因此,我现在使用情节提要页面控制器ui对象将其拖放到如何与页面视图控制器方法连接以及如何通过使用pageviewcontroller图像数组计数来使点移动。

func configurePageControl() {
        // The total number of pages that are available is based on how many available colors we have.
        //pageControl = UIPageControl(frame: CGRect(x: 0,y: UIScreen.main.bounds.maxY - 50,width: UIScreen.main.bounds.width,height: 50))
        pageControl = UIPageControl(frame: CGRect(x: self.containerview.frame.size.width / 2, y: self.containerview.frame.size.height - 50,width: UIScreen.main.bounds.width,height: 50))

        self.pageControl.numberOfPages = pageTitles.count
        self.pageControl.currentPage = 0
        self.pageControl.tintColor = UIColor.black
        self.pageControl.pageIndicatorTintColor = UIColor.white
        self.pageControl.currentPageIndicatorTintColor = UIColor.black
        //self.containerview.addSubview(pageControl)
    }

    // MARK: Delegate functions
    func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
        let pageContentViewController = pageViewController.viewControllers![0]
        //self.pageControl.currentPage = pageTitles.index(of: pageContentViewController)!
    }

1 个答案:

答案 0 :(得分:0)

Mymodel.human_attribute_name(:api_key, count: 2)

更新

func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {

if let viewController = pageViewController.viewControllers?[0] {
    guard let index = arrayVCs.index(of: viewController) else {
        return
    }
    //you can find index here..
    self.pageControl.currentPage = index
}
}
  

将标签设置为您的viewcontrollers视图。