我的观点结构首先是SWRevealViewController
。这需要两个参数。第一个参数是TableViewController
看起来很好。第二个参数是pageViewController
。 pageViewController有两个"页面",每个页面都是NavigationViewController
。 NavigationViewControllers
将以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;