Implement PageViewController in TableViewController details

大憨熊 提交于 2019-12-11 19:39:35

问题


I created my project based on single view application. My application at first has

FoodTableViewContoller --> Details: ItemViewController (Contain "Item" as model).

I have an array named itemArray that contain all the items. I wish to implement pageViewController (or similar other function) that user can swipe right or left to browse the item in itemArray. I followed the tutorial here and further implement in my existing project but it ended up in an infinite loop (Never goes through D log and back to A) when I clicked on one of my table cell. Is it possible to implement pageView in my tableView details?

Here is part of my codes:

NSLog(@"A");
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
                                                          navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                                                                       options:nil];
NSLog(@"B"); 
self.pageViewController.dataSource = self;
ItemViewController *itemViewController = [[ItemViewController alloc] init];
itemViewController.item = self.item;
 NSLog(@"C %@", itemViewController.item);
NSArray *viewControllers = [NSArray arrayWithObject:itemViewController];
NSLog(@"D"); 
[self.pageViewController setViewControllers:viewControllers
                                  direction:UIPageViewControllerNavigationDirectionForward
                                   animated:NO completion:nil];
 NSLog(@"E"); 
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.view addSubview:self.scrollView];
NSLog(@"F");

来源:https://stackoverflow.com/questions/18547555/implement-pageviewcontroller-in-tableviewcontroller-details

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!