Example #1
0
        public void initChapterViewController(PageController page)
        {
            if (chapterVC == null)
            {
                //initial chapterVC
                ChapterViewController.pages = secondScroll.pagesController;
                chapterVC                     = new UIPageViewController(UIPageViewControllerTransitionStyle.Scroll, UIPageViewControllerNavigationOrientation.Horizontal, UIPageViewControllerSpineLocation.Min);
                chapterVC.DataSource          = new ChapterViewController.ChapterVCDataSource();
                chapterVC.View.Frame          = Constants.mainFrame;
                chapterVC.DidFinishAnimating += (sender, e) => {
                    if (e.Finished)
                    {
                        if (e.Completed)
                        {
                            foreach (ChapterViewController c in e.PreviousViewControllers)
                            {
                                this.secondScroll.view.AddSubview(c.currentPage.smallImage);
                                c.currentPage.smallImageToPosition(secondScroll, this.currentChapter.pagesStartX);
                                var currentVC = (ChapterViewController)chapterVC.ViewControllers [chapterVC.ViewControllers.Length - 1];
                                currentVC.currentPage.smallImage.Hidden = true;
                                Console.WriteLine("current + " + currentVC.currentPage.pageInfo.chapter + "   prev " + c.currentPage.pageInfo.chapter);
                                if (currentVC.currentPage.pageInfo.chapter != c.currentPage.pageInfo.chapter)
                                {
                                    Console.WriteLine("chapterchanged");
                                    int chapter = currentVC.currentPage.pageInfo.chapter;
                                    this.currentPage    = chapter;
                                    this.currentChapter = this.chaptersController [chapter];
                                    this.drawCurrentChapter();
                                }

                                fixSecondScrollPosition(currentVC.currentPage);
                            }
                        }
                    }
                };
            }

            ChapterViewController contentViewController = new ChapterViewController(page);

            var viewControllers = new List <ChapterViewController>();

            viewControllers.Add(contentViewController);
            chapterVC.SetViewControllers(viewControllers.ToArray(), UIPageViewControllerNavigationDirection.Forward, false, null);

            this.AddChildViewController(this.chapterVC);
            chapterVC.DidMoveToParentViewController(this);
            this.View.AddSubview(chapterVC.View);
            this.chapterScroll.UserInteractionEnabled = false;
            this.secondScroll.UserInteractionEnabled  = false;
        }
Example #2
0
            public override UIViewController GetNextViewController(UIPageViewController pageViewController, UIViewController referenceViewController)
            {
                if (pages == null)
                {
                    return(null);
                }
                var chapterVC    = (ChapterViewController)referenceViewController;
                int currentIndex = chapterVC.currentPage.pageInfo.indexInBook;

                Console.WriteLine(currentIndex + 1 + " / " + pages.Count);
                if (currentIndex == pages.Count - 1)
                {
                    return(null);
                }
                var nextVC = new ChapterViewController(pages [currentIndex + 1]);

                return(nextVC);
            }