0

我有这段代码显示两个视图控制器之间的转换,但问题是我想显示从右到左的转换,就像在推送视图控制器中一样......

        UIViewController *previousController = [self.childViewControllers   objectAtIndex:[self.childViewControllers count]-2];
    [self transitionFromViewController:previousController toViewController:controller duration:0.5 options:UIViewAnimationOptionAllowAnimatedContent animations:NULL completion:NULL];

任何帮助,将不胜感激

4

2 回答 2

1

你可能会使用这样的东西......

(需要 < QuartzCore/QuartzCore.h >)

CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];

        [animation setSubtype:kCATransitionFromLeft];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[previousController layer] addAnimation:animation forKey:@"SwitchToView"];
于 2013-06-24T11:41:13.523 回答
1

我认为这是你想要的更好的方法,

NSMutableArray *vcs =  [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
               UIViewController *previousController = [self.childViewControllers   objectAtIndex:[self.childViewControllers count]-2];

            [vcs insertObject:previousController atIndex:[vcs count]-1];
            [self.navigationController setViewControllers:vcs animated:NO];
        [self.navigationController popViewControllerAnimated:YES];
于 2013-06-24T11:43:58.743 回答