带有两个UINavigationControllers的UIPageView

时间:2014-04-24 05:18:25

标签: ios uinavigationcontroller uipageviewcontroller

我的观点结构首先是SWRevealViewController。这需要两个参数。第一个参数是TableViewController看起来很好。第二个参数是pageViewController。 pageViewController有两个"页面",每个页面都是NavigationViewControllerNavigationViewControllers将以TableViewControllers作为根视图。

我得到的错误如下:由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:'提供的视图控制器数量(2)与数字不匹配要求(1)请求的脊椎位置(UIPageViewControllerSpineLocationMin)'

这是我的代码:

(这是我的应用代表)

MyListsViewController *myListsVC = [[MyListsViewController alloc] init];
SidebarViewController *sidebarVC = [[SidebarViewController alloc] init];
StarredTableViewController *starredListsVC = [[StarredTableViewController alloc] init];

// Create page view controller
self.pageViewController = [[UIPageViewController alloc] init];
//self.pageViewController.dataSource = self;

//PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
//UINavigationController *myListsNav = [myListsNav initWithRootViewController:myListsVC];
UINavigationController *myListsNav = [[UINavigationController alloc] initWithRootViewController:myListsVC];
UINavigationController *starredListsNav = [[UINavigationController alloc] initWithRootViewController:starredListsVC];
//NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
NSArray* viewControllers = [NSArray arrayWithObjects: myListsNav, starredListsNav, nil];

[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

// Change the size of page view controller
self.pageViewController.view.frame = CGRectMake(0, 0, 320, 480);

[self.pageViewController addChildViewController:_pageViewController];
[self.pageViewController.view addSubview:myListsNav.view];
[self.pageViewController didMoveToParentViewController:self.pageViewController];


//UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:myListsVC];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:sidebarVC];




// UIScrollView *scrollViews
    SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:self.pageViewController];

self.window.rootViewController = revealController;

0 个答案:

没有答案