RTL languages ​​uipageviewcontroller animation

I know this question is typical, and it has been asked many times on the forum, but I still can’t solve my problem, so please, if any body can help, it will be BIG :)

I am creating a book application in Arabic and I need to do the uipageview controller transitions from right to left. And that’s all I have to say.

One more thing (if I didn’t explain myself very well), I have an exact need for this thread: How to change the direction of the UIPageViewController paging animation but I couldn’t decide what they were talking about, so if someone could explain it or give me a link where I can, how to do this, would be more than enough :)

+3
source share
3 answers

It can be done this way.

  • Change the pageViewController data source code from viewControllerBeforeViewController to viewControllerAfterViewController

  • Change UIPageViewControllerSpineLocationMin to UIPageViewControllerSpineLocationMax

To verify this, run the website template as universal and change the following in ModelController.m

 - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController { NSUInteger index = [self indexOfViewController:(DataViewController *)viewController]; if (index == NSNotFound) { return nil; } index++; if (index == [self.pageData count]) { return nil; } return [self viewControllerAtIndex:index storyboard:viewController.storyboard]; } - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { NSUInteger index = [self indexOfViewController:(DataViewController *)viewController]; if ((index == 0) || (index == NSNotFound)) { return nil; } index--; return [self viewControllerAtIndex:index storyboard:viewController.storyboard]; } 

and change the UIPageViewControllerSpineLocationMin to UIPageViewControllerSpineLocationMax and swipe the condition (indexOfCurrentViewController% 2 == 0) in the "RootViewController.m"

 - (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation { if (UIInterfaceOrientationIsPortrait(orientation) || ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)) { UIViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0]; NSArray *viewControllers = [NSArray arrayWithObject:currentViewController]; [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; self.pageViewController.doubleSided = NO; return UIPageViewControllerSpineLocationMax; } DataViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0]; NSArray *viewControllers = nil; NSUInteger indexOfCurrentViewController = [self.modelController indexOfViewController:currentViewController]; if (indexOfCurrentViewController == 0 || indexOfCurrentViewController % 2 == 0) { UIViewController *previousViewController = [self.modelController pageViewController:self.pageViewController viewControllerBeforeViewController:currentViewController]; viewControllers = [NSArray arrayWithObjects:previousViewController, currentViewController, nil]; } else { UIViewController *nextViewController = [self.modelController pageViewController:self.pageViewController viewControllerAfterViewController:currentViewController]; viewControllers = [NSArray arrayWithObjects:currentViewController, nextViewController, nil]; } [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; return UIPageViewControllerSpineLocationMid; } 

Source: PageViewControllers Apple Doc

+9
source

You have to immerse yourself in the main graphics and the main animation.

  • Make 2 layers (previous / next and current)
  • When performing "pangesture" (see the Event Handling Guide ), you need to see if he removed the swipe to the left or swipe to the right (previous / next page)
  • Then do a 3D rotation on the layer (s)

here is a good example of turning pages

+1
source

Madev, would you like to use the "PageBased Application" template?

Just run the new xCode project:

In the iOS> Application app, find the page-based app. Click OK, select Options. All you have to do is provide your content (via the "DataSource").

Now this is the hard part ... But here are some tips

http://www.techotopia.com/index.php/Implementing_a_Page_based_iOS_5_iPhone_Application_using_UIPageViewController

http://www.techotopia.com/index.php/An_Example_iOS_5_iPhone_UIPageViewController_Application

+1
source

Source: https://habr.com/ru/post/1401414/


All Articles