Пример #1
0
        public DataViewController GetViewController(int index, UIStoryboard storyboard)
        {
            if (index >= pageData.Count)
            {
                return(null);
            }

            // Create a new view controller and pass suitable data.
            DataViewController dataViewController =
                (DataViewController)storyboard.InstantiateViewController("DataViewController");

            dataViewController.DataObject = pageData[index];

            return(dataViewController);
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ModelController = new ModelController();

            // Configure the page view controller and add it as a child view controller.
            PageViewController = new UIPageViewController(UIPageViewControllerTransitionStyle.PageCurl,
                                                          UIPageViewControllerNavigationOrientation.Horizontal, UIPageViewControllerSpineLocation.Min);
            PageViewController.WeakDelegate = this;

            DataViewController startingViewController = ModelController.GetViewController(0, Storyboard);
            var viewControllers = new UIViewController[] { startingViewController };

            PageViewController.SetViewControllers(viewControllers, UIPageViewControllerNavigationDirection.Forward, false, null);

            PageViewController.WeakDataSource = ModelController;

            AddChildViewController(PageViewController);
            View.AddSubview(PageViewController.View);

            // Set the page view controller's bounds using an inset rect so that self's view is visible around the edges of the pages.
            CGRect pageViewRect = View.Bounds;

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                pageViewRect = new CGRect(pageViewRect.X + 20, pageViewRect.Y + 20, pageViewRect.Width - 40,
                                          pageViewRect.Height - 40);
            }
            PageViewController.View.Frame = pageViewRect;

            PageViewController.DidMoveToParentViewController(this);

            // Add the page view controller's gesture recognizers to the book view controller's view so that the gestures are started more easily.
            View.GestureRecognizers = PageViewController.GestureRecognizers;
        }
Пример #3
0
 public int IndexOf(DataViewController viewController)
 {
     return(pageData.IndexOf(viewController.DataObject));
 }