5

我知道这个问题是典型的,并且在论坛中被问过很多次,但我仍然无法解决我的问题,所以如果有任何机构可以提供帮助,那就太好了:)

我正在用阿拉伯语创建一个图书应用程序,我需要执行 uipageviewcontroller 从右到左的转换。这就是我要说的。

还有一件事(如果我没有很好地解释我自己)我有这个线程的确切需求:如何更改分页卷曲动画的 UIPageViewController 方向,但我无法做出他们所说的解决方案,所以如果有人可以向我解释或给我一个链接,在那里我可以知道如何做到这一点已经绰绰有余了:)

4

3 回答 3

9

可以通过这种方式完成

  1. 将 pageViewController 的数据源代码交换viewControllerBeforeViewControllerviewControllerAfterViewController

  2. 更改UIPageViewControllerSpineLocationMinUIPageViewControllerSpineLocationMax

要检查这一点,请将基于页面的应用程序模板启动为 Universal 并更改以下内容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];
}

并在“RootViewController.m”中更改UIPageViewControllerSpineLocationMinUIPageViewControllerSpineLocationMax滑动 (indexOfCurrentViewController % 2 == 0) 的条件

- (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;
}

资料来源:PageViewControllers Apple Doc

于 2012-06-20T17:20:03.197 回答
1

您应该深入研究核心图形和核心动画。

  1. 制作 2 层(上一个/下一个和当前)
  2. 进行“手势”时(请参阅事件处理指南),您需要查看它是向左滑动还是向右滑动(上一页/下一页)
  3. 然后在图层上执行 3D 旋转

这是一个关于翻页的好例子

于 2012-06-12T19:48:49.867 回答
1

Madev,您不想使用“PageBased Application”模板吗?

只需启动一个新的 xCode 项目:

在 iOS > Application 下,查找 Page-Based Application。点击确定,选择您的选项。您所要做的就是提供您的内容(通过“数据源”)。

现在这是复杂的部分......但这里有一些提示

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

于 2012-06-12T23:57:17.737 回答