带有页面控件的NavigationController中的UIPageViewController中的UITableView

时间:2016-08-17 14:42:42

标签: ios swift uipageviewcontroller

我有以下设置:

UINavigationController - > UIPageViewController->的UITableViewController /的UIViewController / UIViewController中

我的UIPageViewController看起来像这样:

import UIKit

class DailyRoutinePageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {

    var pages = [UIViewController]()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.automaticallyAdjustsScrollViewInsets = false;
        self.delegate = self
        self.dataSource = self

        self.navigationItem.title = getActiveUserName()

        let page1: UIViewController! = storyboard?.instantiateViewControllerWithIdentifier("dailyRoutinePage1")
        let page2: UIViewController! = storyboard?.instantiateViewControllerWithIdentifier("dailyRoutinePage2")
        let page3: UIViewController! = storyboard?.instantiateViewControllerWithIdentifier("dailyRoutinePage3")

        pages.append(page1)
        pages.append(page2)
        pages.append(page3)

        setViewControllers([page1], direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)
    }
    @IBAction func buttonKontakte(sender: AnyObject) {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("careTaker")
        self.presentViewController(vc, animated: true, completion: nil)
    }

    func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? {
        let currentIndex = pages.indexOf(viewController)!
        let previousIndex = abs((currentIndex - 1) % pages.count)
        return pages[previousIndex]
    }

    func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? {
        let currentIndex = pages.indexOf(viewController)!
        let nextIndex = abs((currentIndex + 1) % pages.count)
        return pages[nextIndex]
    }

    func presentationCountForPageViewController(pageViewController: UIPageViewController) -> Int {
        return pages.count
    }

    func presentationIndexForPageViewController(pageViewController: UIPageViewController) -> Int {
        return 0
    }

}

这很好用。我可以滚动浏览所有页面。现在我想添加一个页面控件。我可以为UIPageView添加页面控件。但是如何在UITableViewController中添加一个呢?当我滚动页面时,页面控制滚动页面。我怎样才能让它停滞不前?

另一个问题:PageViewController并不尊重导航标题栏。因此,顶部的Naviagtion栏后面有内容。我该如何解决这个问题?

0 个答案:

没有答案